diff options
Diffstat (limited to 'buffer.cpp')
-rw-r--r-- | buffer.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -62,10 +62,34 @@ void Buffer::receive(const Command &cmd){ tb.erase(cursor.line,cursor.x); renewLayout(screen[0].line,screen[0].part,lastWidth,lastHeight); } + } else if(cmd[0]=="move_forward"){ + if(cursor.line==tb.numLines()-1&&cursor.x==tb.lineLen(cursor.line)){ + bel(); + } else { + if(cursor.x==tb.lineLen(cursor.line)){ + cursor.x=0; + cursor.line++; + } else { + cursor.x++; + } + renewLayout(screen[0].line,screen[0].part,lastWidth,lastHeight); + } + } else if(cmd[0]=="move_backward"){ + if(cursor.line==0&&cursor.x==0){ + bel(); + } else { + if(cursor.x==0){ + cursor.line--; + cursor.x=tb.lineLen(cursor.line); + } else { + cursor.x--; + } + renewLayout(screen[0].line,screen[0].part,lastWidth,lastHeight); + } } else { THROW("Unknown command"); } - cerr<<"New cursor is (line="<<cursor.line<<", x="<<cursor.x<<")"<<endl; + //cerr<<"New cursor is (line="<<cursor.line<<", x="<<cursor.x<<")"<<endl; } static string showChar(char c){ |