aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2002-08-02 11:33:18 +0000
committernyamatongwe <unknown>2002-08-02 11:33:18 +0000
commitbd9e60e9776f3c57fe42312ea7f64011dd350e8f (patch)
treed8dc668361ec94a4ef3135bdcb03010203b8fad8 /src
parent0a42f39c2ede3efac29478571a9713f20294f7e8 (diff)
downloadscintilla-mirror-bd9e60e9776f3c57fe42312ea7f64011dd350e8f.tar.gz
Added keyboard commands to go to start and end of display lines.
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx61
-rw-r--r--src/Editor.h3
-rw-r--r--src/KeyMap.cxx4
3 files changed, 67 insertions, 1 deletions
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},