aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/Scintilla.h4
-rw-r--r--include/Scintilla.iface14
-rw-r--r--src/Editor.cxx61
-rw-r--r--src/Editor.h3
-rw-r--r--src/KeyMap.cxx4
5 files changed, 85 insertions, 1 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 4b8ccd23f..165f504e6 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -418,6 +418,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_LINESCROLLDOWN 2342
#define SCI_LINESCROLLUP 2343
#define SCI_DELETEBACKNOTLINE 2344
+#define SCI_HOMEDISPLAY 2345
+#define SCI_HOMEDISPLAYEXTEND 2346
+#define SCI_LINEENDDISPLAY 2347
+#define SCI_LINEENDDISPLAYEXTEND 2348
#define SCI_MOVECARETINSIDEVIEW 2401
#define SCI_LINELENGTH 2350
#define SCI_BRACEHIGHLIGHT 2351
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index f6e259efc..0f06d0c88 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1119,6 +1119,20 @@ fun void LineScrollUp=2343(,)
# Will not delete the character before at the start of a line.
fun void DeleteBackNotLine=2344(,)
+# Move caret to first position on display line.
+fun void HomeDisplay=2345(,)
+
+# Move caret to first position on display line extending selection to
+# new caret position.
+fun void HomeDisplayExtend=2346(,)
+
+# Move caret to last position on display line.
+fun void LineEndDisplay=2347(,)
+
+# Move caret to last position on display line extending selection to new
+# caret position.
+fun void LineEndDisplayExtend=2348(,)
+
# 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 76dbd1ba7..9651b075d 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -3043,6 +3043,10 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long
case SCI_LINESCROLLDOWN:
case SCI_LINESCROLLUP:
case SCI_DELETEBACKNOTLINE:
+ case SCI_HOMEDISPLAY:
+ case SCI_HOMEDISPLAYEXTEND:
+ case SCI_LINEENDDISPLAY:
+ case SCI_LINEENDDISPLAYEXTEND:
break;
// Filter out all others like display changes. Also, newlines are redundant
@@ -3173,6 +3177,39 @@ void Editor::CursorUpOrDown(int direction, bool extend) {
MovePositionTo(posNew, extend);
}
+int Editor::StartEndDisplayLine(int pos, bool start) {
+ RefreshStyleData();
+ int line = pdoc->LineFromPosition(pos);
+ AutoSurface surface(IsUnicodeMode());
+ LineLayout *ll = RetrieveLineLayout(line);
+ int posRet = INVALID_POSITION;
+ if (surface && ll) {
+ unsigned int posLineStart = pdoc->LineStart(line);
+ LayoutLine(line, surface, vs, ll, wrapWidth);
+ int posInLine = pos - posLineStart;
+ if (posInLine <= ll->maxLineLength) {
+ for (int subLine=0; subLine<ll->lines; subLine++) {
+ if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine+1))) {
+ if (start) {
+ posRet = ll->LineStart(subLine) + posLineStart;
+ } else {
+ if (subLine == ll->lines - 1)
+ posRet = ll->LineStart(subLine+1) + posLineStart;
+ else
+ posRet = ll->LineStart(subLine+1) + posLineStart - 1;
+ }
+ }
+ }
+ }
+ }
+ llc.Dispose(ll);
+ if (posRet == INVALID_POSITION) {
+ return pos;
+ } else {
+ return posRet;
+ }
+}
+
int Editor::KeyCommand(unsigned int iMessage) {
switch (iMessage) {
case SCI_LINEDOWN:
@@ -3407,6 +3444,26 @@ int Editor::KeyCommand(unsigned int iMessage) {
MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(currentPos), 1), true);
SetLastXChosen();
break;
+ case SCI_HOMEDISPLAY:
+ MovePositionTo(MovePositionSoVisible(
+ StartEndDisplayLine(currentPos, true), -1));
+ SetLastXChosen();
+ break;
+ case SCI_HOMEDISPLAYEXTEND:
+ MovePositionTo(MovePositionSoVisible(
+ StartEndDisplayLine(currentPos, true), -1), true);
+ SetLastXChosen();
+ break;
+ case SCI_LINEENDDISPLAY:
+ MovePositionTo(MovePositionSoVisible(
+ StartEndDisplayLine(currentPos, false), 1));
+ SetLastXChosen();
+ break;
+ case SCI_LINEENDDISPLAYEXTEND:
+ MovePositionTo(MovePositionSoVisible(
+ StartEndDisplayLine(currentPos, false), 1), true);
+ SetLastXChosen();
+ break;
}
return 0;
}
@@ -5479,6 +5536,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_WORDPARTRIGHT:
case SCI_WORDPARTRIGHTEXTEND:
case SCI_DELETEBACKNOTLINE:
+ case SCI_HOMEDISPLAY:
+ case SCI_HOMEDISPLAYEXTEND:
+ case SCI_LINEENDDISPLAY:
+ case SCI_LINEENDDISPLAYEXTEND:
return KeyCommand(iMessage);
case SCI_BRACEHIGHLIGHT:
diff --git a/src/Editor.h b/src/Editor.h
index 5c838ebce..800630bbb 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -403,9 +403,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
void PageMove(int direction, bool extend=false);
void ChangeCaseOfSelection(bool makeUpperCase);
void LineTranspose();
- virtual void CancelModes();
+ virtual void CancelModes();
void NewLine();
void CursorUpOrDown(int direction, bool extend=false);
+ int StartEndDisplayLine(int pos, bool start);
virtual int KeyCommand(unsigned int iMessage);
virtual int KeyDefault(int /* key */, int /*modifiers*/);
int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0);
diff --git a/src/KeyMap.cxx b/src/KeyMap.cxx
index 7a19e9e42..c91e6c6cc 100644
--- a/src/KeyMap.cxx
+++ b/src/KeyMap.cxx
@@ -85,10 +85,14 @@ const KeyToCommand KeyMap::MapDefault[] = {
{SCK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND},
{SCK_HOME, SCI_CTRL, SCI_DOCUMENTSTART},
{SCK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND},
+ {SCK_HOME, SCI_ALT, SCI_HOMEDISPLAY},
+ {SCK_HOME, SCI_ASHIFT, SCI_HOMEDISPLAYEXTEND},
{SCK_END, SCI_NORM, SCI_LINEEND},
{SCK_END, SCI_SHIFT, SCI_LINEENDEXTEND},
{SCK_END, SCI_CTRL, SCI_DOCUMENTEND},
{SCK_END, SCI_CSHIFT, SCI_DOCUMENTENDEXTEND},
+ {SCK_END, SCI_ALT, SCI_LINEENDDISPLAY},
+ {SCK_END, SCI_ASHIFT, SCI_LINEENDDISPLAYEXTEND},
{SCK_PRIOR, SCI_NORM, SCI_PAGEUP},
{SCK_PRIOR, SCI_SHIFT, SCI_PAGEUPEXTEND},
{SCK_NEXT, SCI_NORM, SCI_PAGEDOWN},