+ add: Line Comment Add/Remove commands, additonal to existing Toggle

+ chg: Line Comment BockEdit shortcut changed (Ctl+Alt+Q  =>  Alt+Shift+Q)
+ chg: Line Comment has separate popup menu (Edit -> Selection)
This commit is contained in:
Rainer Kottenhoff 2021-04-19 12:59:42 +02:00
parent 05a7b9f2f8
commit 93ff330060
7 changed files with 211 additions and 206 deletions

View File

@ -650,148 +650,150 @@
#define IDM_EDIT_INSERT_DIRNAME 40353
#define IDM_EDIT_INSERT_PATHNAME 40354
#define IDM_EDIT_LINECOMMENT 40355
#define IDM_EDIT_LINECOMMENT_BLOCKEDIT 40356
#define IDM_EDIT_STREAMCOMMENT 40357
#define IDM_EDIT_URLENCODE 40358
#define IDM_EDIT_URLDECODE 40359
#define IDM_EDIT_URL2PATH 40360
#define IDM_EDIT_PATH2URL 40361
#define IDM_EDIT_INVERTSLASH 40362
#define IDM_EDIT_INVERTBACKSLASH 40363
#define IDM_EDIT_ESCAPECCHARS 40364
#define IDM_EDIT_UNESCAPECCHARS 40365
#define IDM_EDIT_CHAR2HEX 40366
#define IDM_EDIT_HEX2CHAR 40367
#define IDM_EDIT_FINDMATCHINGBRACE 40368
#define IDM_EDIT_SELTOMATCHINGBRACE 40369
#define IDM_EDIT_FIND 40370
#define IDM_EDIT_SAVEFIND 40371
#define IDM_EDIT_FINDNEXT 40372
#define IDM_EDIT_FINDPREV 40373
#define IDM_EDIT_REPLACE 40374
#define IDM_EDIT_REPLACENEXT 40375
#define IDM_EDIT_GOTOLINE 40376
#define IDM_EDIT_SELTONEXT 40377
#define IDM_EDIT_SELTOPREV 40378
#define IDM_EDIT_COMPLETEWORD 40379
#define IDM_EDIT_JOINLN_NOSP 40380
#define IDM_EDIT_REMOVEDUPLICATELINES 40381
#define IDM_EDIT_REMOVEEMPTYLINES 40382
#define IDM_EDIT_MERGEEMPTYLINES 40383
#define IDM_EDIT_CLEAR_MARKER 40384
#define IDM_EDIT_CUT_MARKED 40385
#define IDM_EDIT_COPY_MARKED 40386
#define IDM_EDIT_DELETE_MARKED 40387
#define IDM_EDIT_LINECOMMENT_ADD 40356
#define IDM_EDIT_LINECOMMENT_REMOVE 40357
#define IDM_EDIT_LINECOMMENT_BLOCKEDIT 40358
#define IDM_EDIT_STREAMCOMMENT 40359
#define IDM_EDIT_URLENCODE 40360
#define IDM_EDIT_URLDECODE 40361
#define IDM_EDIT_URL2PATH 40362
#define IDM_EDIT_PATH2URL 40363
#define IDM_EDIT_INVERTSLASH 40364
#define IDM_EDIT_INVERTBACKSLASH 40365
#define IDM_EDIT_ESCAPECCHARS 40366
#define IDM_EDIT_UNESCAPECCHARS 40367
#define IDM_EDIT_CHAR2HEX 40368
#define IDM_EDIT_HEX2CHAR 40369
#define IDM_EDIT_FINDMATCHINGBRACE 40370
#define IDM_EDIT_SELTOMATCHINGBRACE 40371
#define IDM_EDIT_FIND 40372
#define IDM_EDIT_SAVEFIND 40373
#define IDM_EDIT_FINDNEXT 40374
#define IDM_EDIT_FINDPREV 40375
#define IDM_EDIT_REPLACE 40376
#define IDM_EDIT_REPLACENEXT 40377
#define IDM_EDIT_GOTOLINE 40378
#define IDM_EDIT_SELTONEXT 40379
#define IDM_EDIT_SELTOPREV 40380
#define IDM_EDIT_COMPLETEWORD 40381
#define IDM_EDIT_JOINLN_NOSP 40382
#define IDM_EDIT_REMOVEDUPLICATELINES 40383
#define IDM_EDIT_REMOVEEMPTYLINES 40384
#define IDM_EDIT_MERGEEMPTYLINES 40385
#define IDM_EDIT_CLEAR_MARKER 40386
#define IDM_EDIT_CUT_MARKED 40387
#define IDM_EDIT_COPY_MARKED 40388
#define IDM_EDIT_DELETE_MARKED 40389
#define IDM_VIEW_SCHEME 40400
#define IDM_VIEW_USE2NDDEFAULT 40401
#define IDM_VIEW_SCHEMECONFIG 40402
#define IDM_VIEW_FONT 40403
#define IDM_VIEW_WORDWRAP 40404
#define IDM_VIEW_LONGLINEMARKER 40405
#define IDM_VIEW_SHOWINDENTGUIDES 40406
#define IDM_VIEW_SHOWBLANKS 40407
#define IDM_VIEW_SHOWEOLS 40408
#define IDM_VIEW_WORDWRAPSYMBOLS 40409
#define IDM_VIEW_MATCHBRACES 40410
#define IDM_VIEW_TOGGLE_HILITCURLN 40411
#define IDM_VIEW_HILITCURLN_NONE 40412
#define IDM_VIEW_HILITCURLN_BACK 40413
#define IDM_VIEW_HILITCURLN_FRAME 40414
#define IDM_VIEW_LINENUMBERS 40415
#define IDM_VIEW_BOOKMARK_MARGIN 40416
#define IDM_VIEW_ZOOMIN 40417
#define IDM_VIEW_ZOOMOUT 40418
#define IDM_VIEW_RESETZOOM 40419
#define IDM_VIEW_TABSASSPACES 40420
#define IDM_VIEW_TABSETTINGS 40421
#define IDM_VIEW_WORDWRAPSETTINGS 40422
#define IDM_VIEW_LONGLINESETTINGS 40423
#define IDM_VIEW_AUTOINDENTTEXT 40424
#define IDM_VIEW_AUTOCLOSETAGS 40425
#define IDM_VIEW_REUSEWINDOW 40426
#define IDM_VIEW_STICKYWINPOS 40427
#define IDM_VIEW_ALWAYSONTOP 40428
#define IDM_VIEW_MINTOTRAY 40429
#define IDM_VIEW_TRANSPARENT 40430
#define IDM_VIEW_SINGLEFILEINSTANCE 40431
#define IDM_VIEW_CHANGENOTIFY 40432
#define IDM_VIEW_SHOWFILENAMEONLY 40433
#define IDM_VIEW_SHOWFILENAMEFIRST 40434
#define IDM_VIEW_SHOWFULLPATH 40435
#define IDM_VIEW_SHOWEXCERPT 40436
#define IDM_VIEW_NOESCFUNC 40437
#define IDM_VIEW_ESCMINIMIZE 40438
#define IDM_VIEW_ESCEXIT 40439
#define IDM_VIEW_SAVEBEFORERUNNINGTOOLS 40440
#define IDM_VIEW_NOSAVERECENT 40441
#define IDM_VIEW_NOSAVEFINDREPL 40442
#define IDM_VIEW_MENUBAR 40443
#define IDM_VIEW_TOOLBAR 40444
#define IDM_VIEW_CUSTOMIZETB 40445
#define IDM_VIEW_LOADTHEMETB 40446
#define IDM_VIEW_DPISCALETB 40447
#define IDM_VIEW_STATUSBAR 40448
#define IDM_VIEW_SAVESETTINGS 40449
#define IDM_VIEW_SAVESETTINGSNOW 40450
#define IDM_VIEW_FOLDING 40451
#define IDM_VIEW_TOGGLEFOLDS 40452
#define IDM_VIEW_TOGGLE_CURRENT_FOLD 40453
#define IDM_VIEW_MARKOCCUR_ONOFF 40454
#define IDM_VIEW_MARKOCCUR_BOOKMARKS 40455
#define IDM_VIEW_MARKOCCUR_CASE 40456
#define IDM_VIEW_MARKOCCUR_WNONE 40457
#define IDM_VIEW_MARKOCCUR_WORD 40458
#define IDM_VIEW_MARKOCCUR_CURRENT 40459
#define IDM_VIEW_MARKOCCUR_VISIBLE 40460
#define IDM_VIEW_AUTOCOMPLETEWORDS 40461
#define IDM_VIEW_AUTOCLEXKEYWORDS 40462
#define IDM_VIEW_ACCELWORDNAV 40463
#define IDM_VIEW_NOPRESERVECARET 40464
#define IDM_VIEW_HYPERLINKHOTSPOTS 40465
#define IDM_VIEW_COLORDEFHOTSPOTS 40466
#define IDM_VIEW_COLOR_ARGB 40467
#define IDM_VIEW_COLOR_RGBA 40468
#define IDM_VIEW_COLOR_BGRA 40469
#define IDM_VIEW_CURRENTSCHEME 40470
#define IDM_VIEW_SCROLLPASTEOF 40471
#define IDM_VIEW_TOGGLE_VIEW 40472
#define IDM_VIEW_FV_FOLD 40473
#define IDM_VIEW_FV_BOOKMARK 40474
#define IDM_VIEW_FV_HIGHLIGHT 40475
#define IDM_VIEW_FV_BKMRKFOLD 40476
#define IDM_VIEW_FV_HIGHLGFOLD 40477
#define IDM_VIEW_CHASING_DOCTAIL 40478
#define IDM_VIEW_TOGGLETB 40479
#define IDM_VIEW_MUTE_MESSAGEBEEP 40480
#define IDM_VIEW_SHOW_HYPLNK_CALLTIP 40481
#define IDM_VIEW_SPLIT_UNDOTYPSEQ_LNBRK 40482
#define IDM_VIEW_EVALTINYEXPRONSEL 40483
#define IDM_VIEW_UNICODE_POINTS 40484
#define IDM_VIEW_WIN_DARK_MODE 40485
#define IDM_VIEW_SCHEME 41000
#define IDM_VIEW_USE2NDDEFAULT 41001
#define IDM_VIEW_SCHEMECONFIG 41002
#define IDM_VIEW_FONT 41003
#define IDM_VIEW_WORDWRAP 41004
#define IDM_VIEW_LONGLINEMARKER 41005
#define IDM_VIEW_SHOWINDENTGUIDES 41006
#define IDM_VIEW_SHOWBLANKS 41007
#define IDM_VIEW_SHOWEOLS 41008
#define IDM_VIEW_WORDWRAPSYMBOLS 41009
#define IDM_VIEW_MATCHBRACES 41010
#define IDM_VIEW_TOGGLE_HILITCURLN 41011
#define IDM_VIEW_HILITCURLN_NONE 41012
#define IDM_VIEW_HILITCURLN_BACK 41013
#define IDM_VIEW_HILITCURLN_FRAME 41014
#define IDM_VIEW_LINENUMBERS 41015
#define IDM_VIEW_BOOKMARK_MARGIN 41016
#define IDM_VIEW_ZOOMIN 41017
#define IDM_VIEW_ZOOMOUT 41018
#define IDM_VIEW_RESETZOOM 41019
#define IDM_VIEW_TABSASSPACES 41020
#define IDM_VIEW_TABSETTINGS 41021
#define IDM_VIEW_WORDWRAPSETTINGS 41022
#define IDM_VIEW_LONGLINESETTINGS 41023
#define IDM_VIEW_AUTOINDENTTEXT 41024
#define IDM_VIEW_AUTOCLOSETAGS 41025
#define IDM_VIEW_REUSEWINDOW 41026
#define IDM_VIEW_STICKYWINPOS 41027
#define IDM_VIEW_ALWAYSONTOP 41028
#define IDM_VIEW_MINTOTRAY 41029
#define IDM_VIEW_TRANSPARENT 41030
#define IDM_VIEW_SINGLEFILEINSTANCE 41031
#define IDM_VIEW_CHANGENOTIFY 41032
#define IDM_VIEW_SHOWFILENAMEONLY 41033
#define IDM_VIEW_SHOWFILENAMEFIRST 41034
#define IDM_VIEW_SHOWFULLPATH 41035
#define IDM_VIEW_SHOWEXCERPT 41036
#define IDM_VIEW_NOESCFUNC 41037
#define IDM_VIEW_ESCMINIMIZE 41038
#define IDM_VIEW_ESCEXIT 41039
#define IDM_VIEW_SAVEBEFORERUNNINGTOOLS 41040
#define IDM_VIEW_NOSAVERECENT 41041
#define IDM_VIEW_NOSAVEFINDREPL 41042
#define IDM_VIEW_MENUBAR 41043
#define IDM_VIEW_TOOLBAR 41044
#define IDM_VIEW_CUSTOMIZETB 41045
#define IDM_VIEW_LOADTHEMETB 41046
#define IDM_VIEW_DPISCALETB 41047
#define IDM_VIEW_STATUSBAR 41048
#define IDM_VIEW_SAVESETTINGS 41049
#define IDM_VIEW_SAVESETTINGSNOW 41050
#define IDM_VIEW_FOLDING 41051
#define IDM_VIEW_TOGGLEFOLDS 41052
#define IDM_VIEW_TOGGLE_CURRENT_FOLD 41053
#define IDM_VIEW_MARKOCCUR_ONOFF 41054
#define IDM_VIEW_MARKOCCUR_BOOKMARKS 41055
#define IDM_VIEW_MARKOCCUR_CASE 41056
#define IDM_VIEW_MARKOCCUR_WNONE 41057
#define IDM_VIEW_MARKOCCUR_WORD 41058
#define IDM_VIEW_MARKOCCUR_CURRENT 41059
#define IDM_VIEW_MARKOCCUR_VISIBLE 41060
#define IDM_VIEW_AUTOCOMPLETEWORDS 41061
#define IDM_VIEW_AUTOCLEXKEYWORDS 41062
#define IDM_VIEW_ACCELWORDNAV 41063
#define IDM_VIEW_NOPRESERVECARET 41064
#define IDM_VIEW_HYPERLINKHOTSPOTS 41065
#define IDM_VIEW_COLORDEFHOTSPOTS 41066
#define IDM_VIEW_COLOR_ARGB 41067
#define IDM_VIEW_COLOR_RGBA 41068
#define IDM_VIEW_COLOR_BGRA 41069
#define IDM_VIEW_CURRENTSCHEME 41070
#define IDM_VIEW_SCROLLPASTEOF 41071
#define IDM_VIEW_TOGGLE_VIEW 41072
#define IDM_VIEW_FV_FOLD 41073
#define IDM_VIEW_FV_BOOKMARK 41074
#define IDM_VIEW_FV_HIGHLIGHT 41075
#define IDM_VIEW_FV_BKMRKFOLD 41076
#define IDM_VIEW_FV_HIGHLGFOLD 41077
#define IDM_VIEW_CHASING_DOCTAIL 41078
#define IDM_VIEW_TOGGLETB 41079
#define IDM_VIEW_MUTE_MESSAGEBEEP 41080
#define IDM_VIEW_SHOW_HYPLNK_CALLTIP 41081
#define IDM_VIEW_SPLIT_UNDOTYPSEQ_LNBRK 41082
#define IDM_VIEW_EVALTINYEXPRONSEL 41083
#define IDM_VIEW_UNICODE_POINTS 41084
#define IDM_VIEW_WIN_DARK_MODE 41085
// keep Scintilla(SC) order
#define IDM_SET_RENDER_TECH_GDI 40500 // SC_TECHNOLOGY_DEFAULT(0)
#define IDM_SET_RENDER_TECH_D2D 40501 // SC_TECHNOLOGY_DIRECTWRITE(1)
#define IDM_SET_RENDER_TECH_D2DRETAIN 40502 // SC_TECHNOLOGY_DIRECTWRITERETAIN(2)
#define IDM_SET_RENDER_TECH_D2DDC 40503 // SC_TECHNOLOGY_DIRECTWRITEDC(3)
#define IDM_SET_RTL_LAYOUT_EDIT 40504
#define IDM_SET_RTL_LAYOUT_DLG 40505
#define IDM_SET_RENDER_TECH_GDI 42000 // SC_TECHNOLOGY_DEFAULT(0)
#define IDM_SET_RENDER_TECH_D2D 42001 // SC_TECHNOLOGY_DIRECTWRITE(1)
#define IDM_SET_RENDER_TECH_D2DRETAIN 42002 // SC_TECHNOLOGY_DIRECTWRITERETAIN(2)
#define IDM_SET_RENDER_TECH_D2DDC 42003 // SC_TECHNOLOGY_DIRECTWRITEDC(3)
#define IDM_SET_RTL_LAYOUT_EDIT 42004
#define IDM_SET_RTL_LAYOUT_DLG 42005
// keep Scintilla(SC) order
#define IDM_SET_BIDIRECTIONAL_NONE 40506 // SC_BIDIRECTIONAL_DISABLED(0)
#define IDM_SET_BIDIRECTIONAL_L2R 40507 // SC_BIDIRECTIONAL_L2R(1)
#define IDM_SET_BIDIRECTIONAL_R2L 40508 // SC_BIDIRECTIONAL_R2L(2)
#define IDM_SET_BIDIRECTIONAL_NONE 42006 // SC_BIDIRECTIONAL_DISABLED(0)
#define IDM_SET_BIDIRECTIONAL_L2R 42007 // SC_BIDIRECTIONAL_L2R(1)
#define IDM_SET_BIDIRECTIONAL_R2L 42008 // SC_BIDIRECTIONAL_R2L(2)
#define IDM_HELP_ABOUT 40600
#define IDM_HELP_CMD 40601
#define IDM_HELP_ONLINEDOCUMENTATION 40602
#define IDM_HELP_ADMINEXE 40603
#define IDM_HELP_UPDATEWEBSITE 40604
#define IDM_HELP_ABOUT 43000
#define IDM_HELP_CMD 43001
#define IDM_HELP_ONLINEDOCUMENTATION 43002
#define IDM_HELP_ADMINEXE 43003
#define IDM_HELP_UPDATEWEBSITE 43004
#define IDM_TRAY_RESTORE 40700
#define IDM_TRAY_EXIT 40701
#define IDM_SETPASS 40702
#define IDM_EDIT_INSERT_GUID 40705
#define IDM_TRAY_RESTORE 43700
#define IDM_TRAY_EXIT 43701
#define IDM_SETPASS 43702
#define IDM_EDIT_INSERT_GUID 43705
#define IDS_ENC_ANSI 61000

View File

@ -206,13 +206,18 @@ BEGIN
END
POPUP "&Selektion"
BEGIN
MENUITEM "&Text Einrückung", IDM_EDIT_INDENT
MENUITEM "Text &Rückzug", IDM_EDIT_UNINDENT
MENUITEM "&Text Einrückung", IDM_EDIT_INDENT
MENUITEM "Text &Rückzug", IDM_EDIT_UNINDENT
MENUITEM SEPARATOR
MENUITEM "&Zeilenkommentar (Toggle)\tCtrl+Q", IDM_EDIT_LINECOMMENT
MENUITEM "&Erweiterter Zeilenkommentar\tCtrl+Alt+Q", IDM_EDIT_LINECOMMENT_BLOCKEDIT
POPUP "&Zeilenkommentar"
BEGIN
MENUITEM "&Toggle\tCtrl+Q", IDM_EDIT_LINECOMMENT
MENUITEM "&Einfügen\tCtrl+Alt+Q", IDM_EDIT_LINECOMMENT_ADD
MENUITEM "Ent&fernen)\tCtrl+Alt+Shift+Q", IDM_EDIT_LINECOMMENT_REMOVE
MENUITEM "&Bearbeitung\tAlt+Shift+Q", IDM_EDIT_LINECOMMENT_BLOCKEDIT
END
MENUITEM SEPARATOR
MENUITEM "&Mehrzeilenkommentar\tCtrl+Shift+Q", IDM_EDIT_STREAMCOMMENT
MENUITEM "&Mehrzeilenkommentar\tCtrl+Shift+Q", IDM_EDIT_STREAMCOMMENT
MENUITEM SEPARATOR
POPUP "&Umschließe Selektion"
BEGIN

View File

@ -209,10 +209,15 @@ BEGIN
MENUITEM "&Indent", IDM_EDIT_INDENT
MENUITEM "&Unindent", IDM_EDIT_UNINDENT
MENUITEM SEPARATOR
MENUITEM "Line &Comment (Toggle)\tCtrl+Q", IDM_EDIT_LINECOMMENT
MENUITEM "Line Comment Bl&ock Edit\tCtrl+Alt+Q", IDM_EDIT_LINECOMMENT_BLOCKEDIT
POPUP "Line &Comment"
BEGIN
MENUITEM "&Toggle\tCtrl+Q", IDM_EDIT_LINECOMMENT
MENUITEM "&Add\tCtrl+Alt+Q", IDM_EDIT_LINECOMMENT_ADD
MENUITEM "&Remove\tCtrl+Alt+Shift+Q", IDM_EDIT_LINECOMMENT_REMOVE
MENUITEM "&Block Edit\tAlt+Shift+Q", IDM_EDIT_LINECOMMENT_BLOCKEDIT
END
MENUITEM SEPARATOR
MENUITEM "St&ream Comment\tCtrl+Shift+Q", IDM_EDIT_STREAMCOMMENT
MENUITEM "St&ream Comment\tCtrl+Shift+Q", IDM_EDIT_STREAMCOMMENT
MENUITEM SEPARATOR
POPUP "&Enclose Selection"
BEGIN

View File

@ -3498,8 +3498,8 @@ void EditEncloseSelection(LPCWSTR pwszOpen, LPCWSTR pwszClose)
//
// EditToggleLineCommentsSimple()
//
void EditToggleLineCommentsSimple(LPCWSTR pwszComment, bool bInsertAtStart)
{
void EditToggleLineCommentsSimple(LPCWSTR pwszComment, bool bInsertAtStart, LnCmtMode_t mode) {
_SAVE_TARGET_RANGE_;
bool const bStraightSel = SciCall_GetAnchor() <= SciCall_GetCurrentPos();
@ -3559,78 +3559,54 @@ void EditToggleLineCommentsSimple(LPCWSTR pwszComment, bool bInsertAtStart)
UndoTransActionBegin();
int iAction = 0;
bool const bKeepActionOf1stLine = false;
for (DocLn iLine = iLineStart; iLine <= iLineEnd; ++iLine) {
if (!bKeepActionOf1stLine) {
iAction = 0;
}
DocPos const iIndentPos = SciCall_GetLineIndentPosition(iLine);
if (iIndentPos == SciCall_GetLineEndPosition(iLine)) {
// don't set comment char on "empty" (white-space only) lines
//~iAction = 1;
//~iAction = LNC_ADD;
continue;
}
const char* tchBuf = SciCall_GetRangePointer(iIndentPos, cchComment + 1);
if (StrCmpNA(tchBuf, mszComment, (int)cchComment) == 0) {
// remove comment chars incl. Postfix
DocPos const iSelPos = iIndentPos + cchComment;
switch (iAction) {
case 0:
iAction = 2;
case 2:
bool const bHasLnCmnt = (StrCmpNA(tchBuf, mszComment, (int)cchComment) == 0);
bool const bHasPrefix = (StrCmpNA(tchBuf, mszPrefix, (int)cchPrefix) == 0);
int iAction = (mode == LNC_TOGGLE) ? ((bHasLnCmnt || bHasPrefix) ? LNC_REMOVE : LNC_ADD) : mode;
switch (iAction) {
case LNC_ADD: {
DocPos const iPos = SciCall_FindColumn(iLine, iCommentCol);
SciCall_InsertText(iPos, mszComment);
if (iLine == iLineStart) {
iSelStartOffset += (iSelStart <= iPos) ? 0 : cchComment;
}
DocPos const movedSelEnd = iSelEnd + iSelEndOffset;
iSelEndOffset += (movedSelEnd <= iPos) ? 0 : cchComment;
}
break;
case LNC_REMOVE: {
if (bHasLnCmnt || bHasPrefix) {
// remove comment chars (incl. Postfix)
DocPos const cch = bHasLnCmnt ? cchComment : cchPrefix;
DocPos const iSelPos = iIndentPos + cch;
SciCall_SetTargetRange(iIndentPos, iSelPos);
SciCall_ReplaceTarget(-1, "");
if (iLine == iLineStart) {
iSelStartOffset -= (iSelStart <= iIndentPos) ? 0 : (iSelStart < iSelPos) ? (iSelStart - iIndentPos) : cchComment;
iSelStartOffset -= (iSelStart <= iIndentPos) ? 0 : (iSelStart < iSelPos) ? (iSelStart - iIndentPos)
: cch;
}
DocPos const movedSelEnd = iSelEnd + iSelEndOffset;
iSelEndOffset -= (movedSelEnd < iIndentPos) ? 0 : (movedSelEnd < iSelPos) ? (movedSelEnd - iIndentPos) : cchComment;
break;
case 1:
break;
}
} else if (StrCmpNA(tchBuf, mszPrefix, (int)cchPrefix) == 0) {
// remove pure comment chars
DocPos const iSelPos = iIndentPos + cchPrefix;
switch (iAction) {
case 0:
iAction = 2;
case 2:
SciCall_SetTargetRange(iIndentPos, iSelPos);
SciCall_ReplaceTarget(-1, "");
if (iLine == iLineStart) {
iSelStartOffset -= (iSelStart <= iIndentPos) ? 0 : (iSelStart < iSelPos) ? (iSelStart - iIndentPos) : cchPrefix;
}
DocPos const movedSelEnd = iSelEnd + iSelEndOffset;
iSelEndOffset -= (movedSelEnd < iIndentPos) ? 0 : (movedSelEnd < iSelPos) ? (movedSelEnd - iIndentPos) : cchPrefix;
break;
case 1:
break;
}
} else {
// set comment chars at indent pos
switch (iAction) {
case 0:
iAction = 1;
case 1: {
DocPos const iPos = SciCall_FindColumn(iLine, iCommentCol);
SciCall_InsertText(iPos, mszComment);
if (iLine == iLineStart) {
iSelStartOffset += (iSelStart <= iPos) ? 0 : cchComment;
}
DocPos const movedSelEnd = iSelEnd + iSelEndOffset;
iSelEndOffset += (movedSelEnd <= iPos) ? 0 : cchComment;
iSelEndOffset -= (movedSelEnd < iIndentPos) ? 0 : (movedSelEnd < iSelPos) ? (movedSelEnd - iIndentPos)
: cch;
}
}
break;
default:
case LNC_TOGGLE:
break;
case 2:
break;
}
}
}

View File

@ -70,8 +70,8 @@ void EditModifyLines(LPCWSTR pwszPrefix, LPCWSTR pwszAppend);
void EditIndentBlock(HWND hwnd,int cmd, bool bFormatIndentation, bool bForceAll);
void EditAlignText(int nMode);
void EditEncloseSelection(LPCWSTR pwszOpen,LPCWSTR pwszClose);
//void EditToggleLineComments(HWND hwnd, LPCWSTR pwszComment, bool bInsertAtStart);
void EditToggleLineCommentsSimple(LPCWSTR pwszComment, bool bInsertAtStart);
typedef enum _lncmntmode { LNC_TOGGLE, LNC_ADD, LNC_REMOVE } LnCmtMode_t;
void EditToggleLineCommentsSimple(LPCWSTR pwszComment, bool bInsertAtStart, LnCmtMode_t mode);
void EditToggleLineCommentsExtended(LPCWSTR pwszComment, bool bInsertAtStart);
void EditPadWithSpaces(HWND hwnd, bool bSkipEmpty, bool bNoUndoGroup);
void EditStripFirstCharacter(HWND hwnd);

View File

@ -3646,6 +3646,9 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
WCHAR cmnt[8];
Lexer_GetLineCommentStrg(cmnt, COUNTOF(cmnt));
EnableCmd(hmenu, IDM_EDIT_LINECOMMENT, StrIsNotEmpty(cmnt) && !ro);
EnableCmd(hmenu, IDM_EDIT_LINECOMMENT_ADD, StrIsNotEmpty(cmnt) && !ro);
EnableCmd(hmenu, IDM_EDIT_LINECOMMENT_REMOVE, StrIsNotEmpty(cmnt) && !ro);
EnableCmd(hmenu, IDM_EDIT_LINECOMMENT_BLOCKEDIT, StrIsNotEmpty(cmnt) && !ro);
Lexer_GetStreamCommentStrgs(cmnt, cmnt, COUNTOF(cmnt));
EnableCmd(hmenu, IDM_EDIT_STREAMCOMMENT, StrIsNotEmpty(cmnt) && !ro);
@ -4830,11 +4833,23 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break;
case IDM_EDIT_LINECOMMENT: {
case IDM_EDIT_LINECOMMENT:
case IDM_EDIT_LINECOMMENT_ADD:
case IDM_EDIT_LINECOMMENT_REMOVE: {
WCHAR comment[8] = { L'\0' };
bool const bAtStart = Lexer_GetLineCommentStrg(comment, COUNTOF(comment));
if (StrIsNotEmpty(comment)) {
EditToggleLineCommentsSimple(comment, bAtStart);
switch (iLoWParam) {
case IDM_EDIT_LINECOMMENT_ADD:
EditToggleLineCommentsSimple(comment, bAtStart, LNC_ADD);
break;
case IDM_EDIT_LINECOMMENT_REMOVE:
EditToggleLineCommentsSimple(comment, bAtStart, LNC_REMOVE);
break;
default:
EditToggleLineCommentsSimple(comment, bAtStart, LNC_TOGGLE);
break;
}
}
}
break;

View File

@ -286,7 +286,9 @@ BEGIN
"Q", IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT
"Q", IDM_EDIT_ENCLOSESELECTION, VIRTKEY, ALT, NOINVERT /// NO Menu
"Q", IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL, NOINVERT
"Q", IDM_EDIT_LINECOMMENT_BLOCKEDIT, VIRTKEY, CONTROL, ALT, NOINVERT
"Q", IDM_EDIT_LINECOMMENT_ADD, VIRTKEY, CONTROL, ALT, NOINVERT
"Q", IDM_EDIT_LINECOMMENT_REMOVE, VIRTKEY, CONTROL, SHIFT, ALT, NOINVERT
"Q", IDM_EDIT_LINECOMMENT_BLOCKEDIT, VIRTKEY, SHIFT, ALT, NOINVERT
"R", IDM_FILE_RUN, VIRTKEY, CONTROL, NOINVERT
"R", IDM_EDIT_REMOVEEMPTYLINES, VIRTKEY, ALT, NOINVERT /// NO Menu
"R", IDM_EDIT_UNESCAPECCHARS, VIRTKEY, CONTROL, ALT, NOINVERT