[NEW_FEATURE] (Author: Andreas Jonsson) Add new feature: Ctrl+Alt+Enter insert blank line above the current line, Ctrl+Alt+Shift+Enter insert blank line below the current line.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1094 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
8fe56ada57
commit
3f9b573aad
@ -258,6 +258,8 @@ BEGIN
|
||||
MENUITEM "Move Down Current Line", IDM_EDIT_LINE_DOWN
|
||||
MENUITEM "Remove Empty Lines", IDM_EDIT_REMOVEEMPTYLINES
|
||||
MENUITEM "Remove Empty Lines (Containing Blank characters)", IDM_EDIT_REMOVEEMPTYLINESWITHBLANK
|
||||
MENUITEM "Insert Blank Line Above Current", IDM_EDIT_BLANKLINEABOVECURRENT
|
||||
MENUITEM "Insert Blank Line Below Current", IDM_EDIT_BLANKLINEBELOWCURRENT
|
||||
END
|
||||
POPUP "Comment/Uncomment"
|
||||
BEGIN
|
||||
|
@ -315,6 +315,18 @@ void Notepad_plus::command(int id)
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_EDIT_BLANKLINEABOVECURRENT:
|
||||
{
|
||||
_pEditView->insertNewLineAboveCurrentLine();
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_EDIT_BLANKLINEBELOWCURRENT:
|
||||
{
|
||||
_pEditView->insertNewLineBelowCurrentLine();
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_EDIT_CHAR_PANEL:
|
||||
{
|
||||
launchAnsiCharPanel();
|
||||
@ -2481,6 +2493,8 @@ void Notepad_plus::command(int id)
|
||||
case IDM_EDIT_RTL :
|
||||
case IDM_EDIT_LTR :
|
||||
case IDM_EDIT_BEGINENDSELECT:
|
||||
case IDM_EDIT_BLANKLINEABOVECURRENT:
|
||||
case IDM_EDIT_BLANKLINEBELOWCURRENT:
|
||||
case IDM_VIEW_FULLSCREENTOGGLE :
|
||||
case IDM_VIEW_ALWAYSONTOP :
|
||||
case IDM_VIEW_WRAP :
|
||||
|
@ -120,7 +120,8 @@ WinMenuKeyDefinition winKeyDefs[] = {
|
||||
{VK_SPACE, IDM_EDIT_FUNCCALLTIP, true, false, true, NULL},
|
||||
{VK_R, IDM_EDIT_RTL, true, true, false, NULL},
|
||||
{VK_L, IDM_EDIT_LTR, true, true, false, NULL},
|
||||
|
||||
{VK_RETURN, IDM_EDIT_BLANKLINEABOVECURRENT, true, true, false, NULL},
|
||||
{VK_RETURN, IDM_EDIT_BLANKLINEBELOWCURRENT, true, true, true, NULL},
|
||||
{VK_F, IDM_SEARCH_FIND, true, false, false, NULL},
|
||||
{VK_F, IDM_SEARCH_FINDINFILES, true, false, true, NULL},
|
||||
{VK_F3, IDM_SEARCH_FINDNEXT, false, false, false, NULL},
|
||||
|
@ -3005,3 +3005,60 @@ void ScintillaEditView::setTabSettings(Lang *lang)
|
||||
execute(SCI_SETUSETABS, !nppgui._tabReplacedBySpace);
|
||||
}
|
||||
}
|
||||
|
||||
void ScintillaEditView::insertNewLineAboveCurrentLine()
|
||||
{
|
||||
const int eol_mode = int(execute(SCI_GETEOLMODE));
|
||||
|
||||
generic_string newline;
|
||||
if(eol_mode == SC_EOL_CRLF)
|
||||
newline = TEXT("\r\n");
|
||||
else if(eol_mode == SC_EOL_LF)
|
||||
newline = TEXT("\n");
|
||||
else
|
||||
newline = TEXT("\r");
|
||||
|
||||
const int current_line = getCurrentLineNumber();
|
||||
if(current_line == 0)
|
||||
{
|
||||
// Special handling if caret is at first line.
|
||||
insertGenericTextFrom(0, newline.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
const int eol_length = eol_mode == SC_EOL_CRLF ? 2 : 1;
|
||||
const long position = execute(SCI_POSITIONFROMLINE, current_line) - eol_length;
|
||||
insertGenericTextFrom(position, newline.c_str());
|
||||
}
|
||||
execute(SCI_SETEMPTYSELECTION, execute(SCI_POSITIONFROMLINE, current_line));
|
||||
}
|
||||
|
||||
|
||||
void ScintillaEditView::insertNewLineBelowCurrentLine()
|
||||
{
|
||||
const int eol_mode = int(execute(SCI_GETEOLMODE));
|
||||
|
||||
generic_string newline;
|
||||
if(eol_mode == SC_EOL_CRLF)
|
||||
newline = TEXT("\r\n");
|
||||
else if(eol_mode == SC_EOL_LF)
|
||||
newline = TEXT("\n");
|
||||
else
|
||||
newline = TEXT("\r");
|
||||
|
||||
const int line_count = execute(SCI_GETLINECOUNT);
|
||||
const int current_line = getCurrentLineNumber();
|
||||
if(current_line == line_count - 1)
|
||||
{
|
||||
// Special handling if caret is at last line.
|
||||
appandGenericText(newline.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
const int eol_length = eol_mode == SC_EOL_CRLF ? 2 : 1;
|
||||
const long position = eol_length + execute(SCI_GETLINEENDPOSITION, current_line);
|
||||
insertGenericTextFrom(position, newline.c_str());
|
||||
}
|
||||
execute(SCI_SETEMPTYSELECTION, execute(SCI_POSITIONFROMLINE, current_line + 1));
|
||||
}
|
||||
|
||||
|
@ -272,6 +272,9 @@ public:
|
||||
void getLine(int lineNumber, TCHAR * line, int lineBufferLen);
|
||||
void addText(int length, const char *buf);
|
||||
|
||||
void insertNewLineAboveCurrentLine();
|
||||
void insertNewLineBelowCurrentLine();
|
||||
|
||||
void saveCurrentPos();
|
||||
void restoreCurrentPos();
|
||||
void saveCurrentFold();
|
||||
|
@ -76,6 +76,8 @@
|
||||
#define IDM_EDIT_LOWERCASE (IDM_EDIT + 17)
|
||||
#define IDM_EDIT_REMOVEEMPTYLINES (IDM_EDIT + 55)
|
||||
#define IDM_EDIT_REMOVEEMPTYLINESWITHBLANK (IDM_EDIT + 56)
|
||||
#define IDM_EDIT_BLANKLINEABOVECURRENT (IDM_EDIT + 57)
|
||||
#define IDM_EDIT_BLANKLINEBELOWCURRENT (IDM_EDIT + 58)
|
||||
|
||||
// Menu macro
|
||||
#define IDM_MACRO_STARTRECORDINGMACRO (IDM_EDIT + 18)
|
||||
|
Loading…
Reference in New Issue
Block a user