diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-01-14 23:29:23 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-01-14 23:29:23 +0100 |
commit | c459b19780549efa9a422a5a82a6f38caee75445 (patch) | |
tree | 3ab19385657169a162a5a43cb9158fe1316d6b8a /buffer.cpp | |
parent | dfd6c08655f7a0ac0e93e3227b0b54ef19a6df1f (diff) |
Diffstat (limited to 'buffer.cpp')
-rw-r--r-- | buffer.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
@@ -189,6 +189,42 @@ void Buffer::handleCommand(const Command &cmd){ } else { cursor.x=screen[sp.y].cells[sp.x].linex; } + } else if(cmd[0]=="move_pagedown"){ + Screenpos sp=findCursorInScreen(); + if(sp.x==-1||screen.size()==0){ + bel(); + return; + } + i64 lastLine=screen.back().line; + i64 lastX=screen.back().cells.size()==0 ? screen.back().fromx : screen.back().cells.back().linex+1; + i64 newTopLine,newTopPart; + if(lastX>=tb.lineLen(lastLine)){ + if(lastLine==tb.numLines()-1){ + cursor.line=lastLine; + cursor.x=lastX; + return; + } + newTopLine=lastLine+1; + newTopPart=0; + } else { + newTopLine=lastLine; + newTopPart=screen.back().part+1; + } + vector<ScreenLine> screenCopy=screen; + renewLayout(newTopLine,newTopPart,lastWidth,lastHeight); + if((i64)screen.size()<lastHeight){ + i64 gap=lastHeight-screen.size(); + screen.insert(screen.begin(),screenCopy.begin()+(screenCopy.size()-gap),screenCopy.end()); + cursor.line=screen.back().line; + if(screen.back().cells.size()==0)cursor.x=screen.back().fromx; + else cursor.x=screen.back().cells.back().linex+1; + } else { + cursor.line=screen[sp.y].line; + if((i64)screen[sp.y].cells.size()<sp.x){ + if(screen[sp.y].cells.size()==0)cursor.x=screen[sp.y].fromx; + else cursor.x=screen[sp.y].cells.back().linex+1; + } + } } else if(cmd[0]=="cancel"){ bel(); //nothing to cancel, apparently } else { @@ -347,11 +383,6 @@ void Buffer::renewLayout(i64 topLine,i64 topPart,i64 width,i64 height){ if((i64)screen.size()>height){ screen.resize(height); } - - if(findCursorInScreen().x==-1){ //We lost the cursor! Let's find it again - performInitialLayout(width,height); - cerr<<"Re-performing initial layout because cursor was lost in renewLayout"<<endl; - } } void Buffer::relayoutScreen(){ |