diff options
author | nyamatongwe <unknown> | 2003-03-28 10:30:22 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2003-03-28 10:30:22 +0000 |
commit | 4280d26bd57c1af6fd4f0a66145ce771dbe426dd (patch) | |
tree | b4d345ea3d2742f7d94ccf976fb18528cb7c9ea2 | |
parent | bf2653e0515d95d3aac8053147e143da9acb30de (diff) | |
download | scintilla-mirror-4280d26bd57c1af6fd4f0a66145ce771dbe426dd.tar.gz |
Jakub's paragraph movement commands.
-rw-r--r-- | src/Document.cxx | 29 | ||||
-rw-r--r-- | src/Document.h | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 20 | ||||
-rw-r--r-- | src/KeyMap.cxx | 4 |
4 files changed, 54 insertions, 1 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 635b380f9..255c9ee11 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -720,6 +720,33 @@ void Document::ConvertLineEnds(int eolModeSet) { EndUndoAction(); } +int Document::ParaDown(int pos) { + int line = LineFromPosition(pos); + while (line < LinesTotal() && LineStart(line) != LineEnd(line)) { // skip non-empty lines + line++; + } + while (line < LinesTotal() && LineStart(line) == LineEnd(line)) { // skip empty lines + line++; + } + if (line < LinesTotal()) + return LineStart(line); + else // end of a document + return LineEnd(line-1); +} + +int Document::ParaUp(int pos) { + int line = LineFromPosition(pos); + line--; + while (line >= 0 && LineStart(line) == LineEnd(line)) { // skip empty lines + line--; + } + while (line >= 0 && LineStart(line) != LineEnd(line)) { // skip non-empty lines + line--; + } + line++; + return LineStart(line); +} + Document::charClassification Document::WordCharClass(unsigned char ch) { if ((SC_CP_UTF8 == dbcsCodePage) && (ch >= 0x80)) return ccWord; @@ -1328,4 +1355,4 @@ int Document::ExtendStyleRange(int pos, int delta) { pos++; } return pos; -}
\ No newline at end of file +} diff --git a/src/Document.h b/src/Document.h index b97abfb4b..bcdbe00ca 100644 --- a/src/Document.h +++ b/src/Document.h @@ -221,6 +221,8 @@ public: int WordPartLeft(int pos); int WordPartRight(int pos); int ExtendStyleRange(int pos, int delta); + int ParaUp(int pos); + int ParaDown(int pos); private: charClassification WordCharClass(unsigned char ch); diff --git a/src/Editor.cxx b/src/Editor.cxx index a610f260f..36390b427 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -3384,8 +3384,12 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_SEARCHPREV: case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: + case SCI_PARADOWN: + case SCI_PARADOWNEXTEND: case SCI_LINEUP: case SCI_LINEUPEXTEND: + case SCI_PARAUP: + case SCI_PARAUPEXTEND: case SCI_CHARLEFT: case SCI_CHARLEFTEXTEND: case SCI_CHARRIGHT: @@ -3622,6 +3626,12 @@ int Editor::KeyCommand(unsigned int iMessage) { case SCI_LINEDOWNEXTEND: CursorUpOrDown(1, true); break; + case SCI_PARADOWN: + MovePositionTo(pdoc->ParaDown(currentPos)); + break; + case SCI_PARADOWNEXTEND: + MovePositionTo(pdoc->ParaDown(currentPos), true); + break; case SCI_LINESCROLLDOWN: ScrollTo(topLine + 1); MoveCaretInsideView(false); @@ -3632,6 +3642,12 @@ int Editor::KeyCommand(unsigned int iMessage) { case SCI_LINEUPEXTEND: CursorUpOrDown(-1, true); break; + case SCI_PARAUP: + MovePositionTo(pdoc->ParaUp(currentPos)); + break; + case SCI_PARAUPEXTEND: + MovePositionTo(pdoc->ParaUp(currentPos), true); + break; case SCI_LINESCROLLUP: ScrollTo(topLine - 1); MoveCaretInsideView(false); @@ -6102,8 +6118,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: + case SCI_PARADOWN: + case SCI_PARADOWNEXTEND: case SCI_LINEUP: case SCI_LINEUPEXTEND: + case SCI_PARAUP: + case SCI_PARAUPEXTEND: case SCI_CHARLEFT: case SCI_CHARLEFTEXTEND: case SCI_CHARRIGHT: diff --git a/src/KeyMap.cxx b/src/KeyMap.cxx index 4e580e8e6..837cdd241 100644 --- a/src/KeyMap.cxx +++ b/src/KeyMap.cxx @@ -66,9 +66,13 @@ const KeyToCommand KeyMap::MapDefault[] = { {SCK_DOWN, SCI_NORM, SCI_LINEDOWN}, {SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND}, {SCK_DOWN, SCI_CTRL, SCI_LINESCROLLDOWN}, + {SCK_DOWN, SCI_ALT, SCI_PARADOWN}, + {SCK_DOWN, SCI_ASHIFT, SCI_PARADOWNEXTEND}, {SCK_UP, SCI_NORM, SCI_LINEUP}, {SCK_UP, SCI_SHIFT, SCI_LINEUPEXTEND}, {SCK_UP, SCI_CTRL, SCI_LINESCROLLUP}, + {SCK_UP, SCI_ALT, SCI_PARAUP}, + {SCK_UP, SCI_ASHIFT, SCI_PARAUPEXTEND}, {SCK_LEFT, SCI_NORM, SCI_CHARLEFT}, {SCK_LEFT, SCI_SHIFT, SCI_CHARLEFTEXTEND}, {SCK_LEFT, SCI_CTRL, SCI_WORDLEFT}, |