From c459b19780549efa9a422a5a82a6f38caee75445 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 14 Jan 2017 23:29:23 +0100 Subject: Add pagedown implementation --- buffer.cpp | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/buffer.cpp b/buffer.cpp index 182c285..b8e0d75 100644 --- a/buffer.cpp +++ b/buffer.cpp @@ -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 screenCopy=screen; + renewLayout(newTopLine,newTopPart,lastWidth,lastHeight); + 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"<