/* move to the start byte if we landed on a continuation */
while(editor.curx>0&&
((unsignedchar)row->line[editor.curx]&
0xC0)==0x80){
editor.curx--;
/* move to the start byte if we landed on a continuation */
while(editor.curx>0&&
((unsignedchar)row->line[editor.curx]&
0xC0)==0x80){
editor.curx--;
}
}elseif(editor.cury>0){
editor.cury--;
editor.curx=editor.row[editor.cury].size;
/* ensure at a codepoint boundary at end of previous line */
row=&editor.row[editor.cury];
while(editor.curx>0&&
((unsignedchar)row->line[editor.curx]&
0xC0)==0x80){
editor.curx--;
}
}
break;
casePG_UP:
casePG_DN:
if(c==PG_UP){
editor.cury=editor.rowoffs;
}elseif(c==PG_DN){
editor.cury=editor.rowoffs+editor.rows-1;
if(editor.cury>editor.nrows){
editor.cury=editor.nrows;
}
}
reps=editor.rows;
while(--reps){
move_cursor(c==PG_UP?ARROW_UP:ARROW_DOWN);
}
break;
caseHOME_KEY:
caseCTRL_KEY('a'):
editor.curx=0;
break;
caseEND_KEY:
caseCTRL_KEY('e'):
if(editor.nrows==0){
break;
}
}elseif(editor.cury>0){
editor.cury--;
editor.curx=editor.row[editor.cury].size;
/* ensure at a codepoint boundary at end of previous line */
row=&editor.row[editor.cury];
while(editor.curx>0&&
((unsignedchar)row->line[editor.curx]&
0xC0)==0x80){
editor.curx--;
}
}
break;
casePG_UP:
casePG_DN:
if(c==PG_UP){
editor.cury=editor.rowoffs;
}elseif(c==PG_DN){
editor.cury=editor.rowoffs+editor.rows-1;
if(editor.cury>editor.nrows){
editor.cury=editor.nrows;
}
}
reps=editor.rows;
while(--reps){
move_cursor(c==PG_UP?ARROW_UP:ARROW_DOWN);
}
break;
caseHOME_KEY:
caseCTRL_KEY('a'):
editor.curx=0;
break;
caseEND_KEY:
caseCTRL_KEY('e'):
if(editor.nrows==0){
break;
default:
break;
}
editor.curx=editor.row[editor.cury].size;
break;
default:
break;
}
@@ -1692,7 +1782,10 @@ newline(void)
{
structerow*row=NULL;
if(editor.curx==0){
if(editor.cury>=editor.nrows){
/* At or past end of file, insert empty line */
erow_insert(editor.cury,"",0);
}elseif(editor.curx==0){
erow_insert(editor.cury,"",0);
}else{
row=&editor.row[editor.cury];
@@ -1919,12 +2012,17 @@ process_normal(int16_t c)
caseESC_KEY:
editor.mode=MODE_ESCAPE;
break;
default:
/* Insert any printable byte: ASCII 0x20–0x7E and all bytes >=0x80. */
if((c==TAB_KEY)||(c>=0x20&&c!=0x7f)){
insertch(c);
}
break;
default:
if(c==TAB_KEY){
if(editor.mark_set){
indent_region();
}else{
insertch(c);
}
}elseif(c>=0x20&&c!=0x7f){
insertch(c);
}
break;
}
editor.dirtyex=1;
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.