mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[qwaq] Implement home and end
Currently, home always moves the cursor to the very first column, but I'm considering making it move the cursor to the first non-space character of the line if it's not already there, otherwise to the first column (ie, the cursor will toggle between the two positions if it's in one of them).
This commit is contained in:
parent
055ea46337
commit
75ce07a14c
2 changed files with 27 additions and 0 deletions
|
@ -47,6 +47,8 @@
|
|||
-charDown;
|
||||
-charLeft;
|
||||
-charRight;
|
||||
-moveBOL;
|
||||
-moveEOL;
|
||||
|
||||
-recenter:(int) force;
|
||||
-gotoLine:(unsigned) line;
|
||||
|
|
|
@ -173,6 +173,12 @@ handleEvent (Editor *self, qwaq_event_t *event)
|
|||
case QFK_RIGHT:
|
||||
[self charRight];
|
||||
return 1;
|
||||
case QFK_HOME:
|
||||
[self moveBOL];
|
||||
return 1;
|
||||
case QFK_END:
|
||||
[self moveEOL];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -370,6 +376,25 @@ handleEvent (Editor *self, qwaq_event_t *event)
|
|||
return self;
|
||||
}
|
||||
|
||||
-moveBOL
|
||||
{
|
||||
char_index = line_index;
|
||||
cursor.x = 0;
|
||||
base.x = 0;
|
||||
[self recenter:0];
|
||||
[self moveCursor: {cursor.x - base.x, cursor.y - base.y}];
|
||||
return self;
|
||||
}
|
||||
|
||||
-moveEOL
|
||||
{
|
||||
char_index = [buffer getEOL:line_index];
|
||||
cursor.x = [buffer charPos:line_index at:char_index];
|
||||
[self recenter:0];
|
||||
[self moveCursor: {cursor.x - base.x, cursor.y - base.y}];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)onScroll:(id)sender
|
||||
{
|
||||
base.x = scroll.x;
|
||||
|
|
Loading…
Reference in a new issue