aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2003-02-23 02:00:53 +0000
committernyamatongwe <devnull@localhost>2003-02-23 02:00:53 +0000
commiteb4c37657c76b04e3b261a568ac88d2f985390f7 (patch)
tree086ff9252089b45351b367a4cc3b4a62ce1c69ef
parent9453a45638f3f7d06f1db441d3d72615d0ca37c3 (diff)
downloadscintilla-mirror-eb4c37657c76b04e3b261a568ac88d2f985390f7.tar.gz
Patch from Bruce Dodson for a variant on home and end keys for wrapped
mode that go to the start/end of the current display line. A second hit goes to the start/end of the document line.
-rw-r--r--include/Scintilla.h6
-rw-r--r--include/Scintilla.iface13
-rw-r--r--src/Editor.cxx64
3 files changed, 83 insertions, 0 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 9f3b9ea34..ecdda8de1 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -454,6 +454,12 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_HOMEDISPLAYEXTEND 2346
#define SCI_LINEENDDISPLAY 2347
#define SCI_LINEENDDISPLAYEXTEND 2348
+#define SCI_HOMEWRAP 2349
+#define SCI_HOMEWRAPEXTEND 2450
+#define SCI_LINEENDWRAP 2451
+#define SCI_LINEENDWRAPEXTEND 2452
+#define SCI_VCHOMEWRAP 2453
+#define SCI_VCHOMEWRAPEXTEND 2454
#define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index b16a729d1..984b4a3d8 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1209,6 +1209,19 @@ fun void LineEndDisplay=2347(,)
# caret position.
fun void LineEndDisplayExtend=2348(,)
+# These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
+# except they behave differently when word-wrap is enabled:
+# They go first to the start / end of the display line, like (Home|LineEnd)Display
+# The difference is that, the cursor is already at the point, it goes on to the start
+# or end of the document line, as appropriate for (Home|LineEnd|VCHome)Extend.
+
+fun void HomeWrap=2349(,)
+fun void HomeWrapExtend=2450(,)
+fun void LineEndWrap=2451(,)
+fun void LineEndWrapExtend=2452(,)
+fun void VCHomeWrap=2453(,)
+fun void VCHomeWrapExtend=2454(,)
+
# Move the caret inside current view if it's not there already.
fun void MoveCaretInsideView=2401(,)
diff --git a/src/Editor.cxx b/src/Editor.cxx
index cc650525a..b156dd3ec 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -3354,6 +3354,10 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long
case SCI_HOMEEXTEND:
case SCI_LINEEND:
case SCI_LINEENDEXTEND:
+ case SCI_HOMEWRAP:
+ case SCI_HOMEWRAPEXTEND:
+ case SCI_LINEENDWRAP:
+ case SCI_LINEENDWRAPEXTEND:
case SCI_DOCUMENTSTART:
case SCI_DOCUMENTSTARTEXTEND:
case SCI_DOCUMENTEND:
@@ -3370,6 +3374,8 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long
case SCI_FORMFEED:
case SCI_VCHOME:
case SCI_VCHOMEEXTEND:
+ case SCI_VCHOMEWRAP:
+ case SCI_VCHOMEWRAPEXTEND:
case SCI_DELWORDLEFT:
case SCI_DELWORDRIGHT:
case SCI_DELLINELEFT:
@@ -3638,6 +3644,38 @@ int Editor::KeyCommand(unsigned int iMessage) {
MovePositionTo(pdoc->LineEndPosition(currentPos), true);
SetLastXChosen();
break;
+ case SCI_HOMEWRAP: {
+ int homePos = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1);
+ if (currentPos <= homePos)
+ homePos = pdoc->LineStart(pdoc->LineFromPosition(currentPos));
+ MovePositionTo(homePos);
+ SetLastXChosen();
+ }
+ break;
+ case SCI_HOMEWRAPEXTEND: {
+ int homePos = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1);
+ if (currentPos <= homePos)
+ homePos = pdoc->LineStart(pdoc->LineFromPosition(currentPos));
+ MovePositionTo(homePos, true);
+ SetLastXChosen();
+ }
+ break;
+ case SCI_LINEENDWRAP: {
+ int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1);
+ if (currentPos >= endPos)
+ endPos = pdoc->LineEndPosition(currentPos);
+ MovePositionTo(endPos);
+ SetLastXChosen();
+ }
+ break;
+ case SCI_LINEENDWRAPEXTEND: {
+ int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1);
+ if (currentPos >= endPos)
+ endPos = pdoc->LineEndPosition(currentPos);
+ MovePositionTo(endPos, true);
+ SetLastXChosen();
+ }
+ break;
case SCI_DOCUMENTSTART:
MovePositionTo(0);
SetLastXChosen();
@@ -3710,6 +3748,26 @@ int Editor::KeyCommand(unsigned int iMessage) {
MovePositionTo(pdoc->VCHomePosition(currentPos), true);
SetLastXChosen();
break;
+ case SCI_VCHOMEWRAP: {
+ int homePos = pdoc->VCHomePosition(currentPos);
+ int viewLineStart = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1);
+ if ((viewLineStart < currentPos) && (viewLineStart > homePos))
+ homePos = viewLineStart;
+
+ MovePositionTo(homePos);
+ SetLastXChosen();
+ }
+ break;
+ case SCI_VCHOMEWRAPEXTEND: {
+ int homePos = pdoc->VCHomePosition(currentPos);
+ int viewLineStart = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1);
+ if ((viewLineStart < currentPos) && (viewLineStart > homePos))
+ homePos = viewLineStart;
+
+ MovePositionTo(homePos, true);
+ SetLastXChosen();
+ }
+ break;
case SCI_ZOOMIN:
if (vs.zoomLevel < 20) {
vs.zoomLevel++;
@@ -5937,6 +5995,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_HOMEEXTEND:
case SCI_LINEEND:
case SCI_LINEENDEXTEND:
+ case SCI_HOMEWRAP:
+ case SCI_HOMEWRAPEXTEND:
+ case SCI_LINEENDWRAP:
+ case SCI_LINEENDWRAPEXTEND:
case SCI_DOCUMENTSTART:
case SCI_DOCUMENTSTARTEXTEND:
case SCI_DOCUMENTEND:
@@ -5954,6 +6016,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_FORMFEED:
case SCI_VCHOME:
case SCI_VCHOMEEXTEND:
+ case SCI_VCHOMEWRAP:
+ case SCI_VCHOMEWRAPEXTEND:
case SCI_ZOOMIN:
case SCI_ZOOMOUT:
case SCI_DELWORDLEFT: