diff --git a/fcore/app-update.sml b/fcore/app-update.sml index da5f781..e76cbcb 100644 --- a/fcore/app-update.sml +++ b/fcore/app-update.sml @@ -24,13 +24,16 @@ struct let val {windowWidth, windowHeight, startLine, ...} = app - (* move LineGap to first line displayed on screen, and build new text *) - val buffer = - LineGap.goToLine (startLine, buffer) + (* move LineGap to first line displayed on screen *) + val buffer = LineGap.goToLine (startLine, buffer) + (* get new startLine which may move screen depending on cursor movements *) val startLine = TextWindow.getStartLine (buffer, startLine, cursorIdx, windowWidth, windowHeight) + (* move buffer to new startLine as required by TextBuilder.build *) + val buffer = LineGap.goToLine (startLine, buffer) + val drawMsg = TextBuilder.build (startLine, cursorIdx, buffer, windowWidth, windowHeight) @@ -59,14 +62,17 @@ struct if count = 0 then let val {windowWidth, windowHeight, startLine, ...} = app - (* todo: get new startLine if cursor has moved out of screen *) - (* move LineGap to first line displayed on screen, and build new text *) + (* move LineGap to first line displayed on screen *) val buffer = LineGap.goToLine (startLine, buffer) + (* get new startLine which may move screen depending on cursor movements *) val startLine = TextWindow.getStartLine (buffer, startLine, cursorIdx, windowWidth, windowHeight) + (* move buffer to new startLine as required by TextBuilder.build *) + val buffer = LineGap.goToLine (startLine, buffer) + val drawMsg = TextBuilder.build (startLine, cursorIdx, buffer, windowWidth, windowHeight) diff --git a/fcore/text-window.sml b/fcore/text-window.sml index 971c2bb..97c30ba 100644 --- a/fcore/text-window.sml +++ b/fcore/text-window.sml @@ -65,7 +65,7 @@ struct if curHeight + (ySpace * 3) >= maxHeight then getStartLineAfter ( sIdx + 1, shd, lineNum + 1, absIdx + 1, cursorIdx, stl - , maxWidth, maxHeight, 0, 0 + , maxWidth, maxHeight, 0, curHeight + ySpace , origLine + 1 ) else @@ -90,13 +90,13 @@ struct if curHeight + (ySpace * 3) >= maxHeight then getStartLineAfter ( sIdx + 1, shd, lineNum + 1, absIdx + 1, cursorIdx, stl - , maxWidth, maxHeight, 0, 0 + , maxWidth, maxHeight, 0, curHeight + ySpace , origLine + 1 ) else getStartLineAfter ( sIdx + 1, shd, lineNum + 1, absIdx + 1, cursorIdx, stl - , maxWidth, maxHeight, 0, 0 + , maxWidth, maxHeight, 0, curHeight + ySpace , origLine ) end @@ -132,12 +132,11 @@ struct (startIdx + 1, rStrHd, oldLine, absIdx + 1, cursorIdx, leftStrings) else if cursorIdx > absIdx then (* possibly move downwards *) - let val _ = print "start 133\n" in getStartLineAfter ( startIdx, rStrHd, oldLine, absIdx, cursorIdx, rStrTl , maxWidth, maxHeight, 0, 0 , oldLine - ) end + ) else (* keep current line *) Int.max (oldLine - 1, 0) diff --git a/shf b/shf index cd46eb6..492b64c 100755 Binary files a/shf and b/shf differ