mirror of https://github.com/adamdruppe/arsd.git
More word forward emacs style controls
This commit is contained in:
parent
f75590c1f4
commit
537a9e6bdf
36
terminal.d
36
terminal.d
|
@ -5296,14 +5296,30 @@ class LineGetter {
|
||||||
//deleteChar();
|
//deleteChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/++
|
||||||
|
Used by the word movement keys (e.g. alt+backspace) to find a word break.
|
||||||
|
|
||||||
|
History:
|
||||||
|
Added April 21, 2021 (dub v9.5)
|
||||||
|
|
||||||
|
Prior to that, [LineGetter] only used [std.uni.isWhite]. Now it uses this which
|
||||||
|
uses if not alphanum and not underscore.
|
||||||
|
|
||||||
|
You can subclass this to customize its behavior.
|
||||||
|
+/
|
||||||
|
bool isWordSeparatorCharacter(dchar d) {
|
||||||
|
import std.uni : isAlphaNum;
|
||||||
|
|
||||||
|
return !(isAlphaNum(d) || d == '_');
|
||||||
|
}
|
||||||
|
|
||||||
private int wordForwardIdx() {
|
private int wordForwardIdx() {
|
||||||
int cursorPosition = this.cursorPosition;
|
int cursorPosition = this.cursorPosition;
|
||||||
import std.uni : isWhite;
|
|
||||||
if(cursorPosition == line.length)
|
if(cursorPosition == line.length)
|
||||||
return cursorPosition;
|
return cursorPosition;
|
||||||
while(cursorPosition + 1 < line.length && isWhite(line[cursorPosition]))
|
while(cursorPosition + 1 < line.length && isWordSeparatorCharacter(line[cursorPosition]))
|
||||||
cursorPosition++;
|
cursorPosition++;
|
||||||
while(cursorPosition + 1 < line.length && !isWhite(line[cursorPosition + 1]))
|
while(cursorPosition + 1 < line.length && !isWordSeparatorCharacter(line[cursorPosition + 1]))
|
||||||
cursorPosition++;
|
cursorPosition++;
|
||||||
cursorPosition += 2;
|
cursorPosition += 2;
|
||||||
if(cursorPosition > line.length)
|
if(cursorPosition > line.length)
|
||||||
|
@ -5324,13 +5340,12 @@ class LineGetter {
|
||||||
maybePositionCursor();
|
maybePositionCursor();
|
||||||
}
|
}
|
||||||
private int wordBackIdx() {
|
private int wordBackIdx() {
|
||||||
import std.uni : isWhite;
|
|
||||||
if(!line.length || !cursorPosition)
|
if(!line.length || !cursorPosition)
|
||||||
return cursorPosition;
|
return cursorPosition;
|
||||||
int ret = cursorPosition - 1;
|
int ret = cursorPosition - 1;
|
||||||
while(ret && isWhite(line[ret]))
|
while(ret && isWordSeparatorCharacter(line[ret]))
|
||||||
ret--;
|
ret--;
|
||||||
while(ret && !isWhite(line[ret - 1]))
|
while(ret && !isWordSeparatorCharacter(line[ret - 1]))
|
||||||
ret--;
|
ret--;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -6052,6 +6067,15 @@ class LineGetter {
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case '(':
|
||||||
|
if(!(ev.modifierState & ModifierState.alt))
|
||||||
|
goto default;
|
||||||
|
justHitTab = justKilled = false;
|
||||||
|
addChar('(');
|
||||||
|
addChar(cast(dchar) (')' | PRIVATE_BITS_MASK));
|
||||||
|
charBack();
|
||||||
|
redraw();
|
||||||
|
break;
|
||||||
case 'l', 12:
|
case 'l', 12:
|
||||||
if(!(ev.modifierState & ModifierState.control))
|
if(!(ev.modifierState & ModifierState.control))
|
||||||
goto default;
|
goto default;
|
||||||
|
|
Loading…
Reference in New Issue