fix ctrl+down

This commit is contained in:
Art 2022-12-29 19:16:18 +01:00
parent 2452633e32
commit 4323e5872c
Signed by: prod2
GPG Key ID: F3BB5A97A70A8DDE
3 changed files with 5 additions and 3 deletions

View File

@ -25,6 +25,7 @@ proc render*(textBuffer: TextBuffer, termBuffer: Buffer, prompt: string, scroll:
if bufWidth != termWidth or bufHeight != min(lineCount, termHeight):
termBuffer.resize(termWidth, min(lineCount, termHeight))
termBuffer.clear()

View File

@ -1,6 +1,7 @@
import unicode
import escapeSequences
import sequtils
import strformat
type
Buffer* = ref object
@ -47,7 +48,7 @@ func getCursorPos*(buf: Buffer): (int, int) =
proc setCursorPos*(buf: Buffer, x, y: int) =
if x < 0 or y < 0 or x >= buf.width or y >= buf.height:
raise newException(ValueError, "Provided x or y out of bounds for SetCursorPos.")
raise newException(ValueError, &"Provided x ({x}) or y ({y}) out of bounds (x: {0}..{buf.width-1}; y: {0}..{buf.height-1}) for SetCursorPos.")
buf.bufferX = x
buf.bufferY = y

View File

@ -97,9 +97,9 @@ proc enter*(buf: TextBuffer) =
proc newLine*(buf: TextBuffer) =
# inserts a new empty line below the current one
# and moves cursor to it
# TODO fix crash
inc buf.cursorY
buf.content.insert(@[], buf.cursorY)
let empty: seq[Rune] = @[]
buf.content.insert(empty, buf.cursorY)
buf.cursorX = 0
proc getLineCount*(buf: TextBuffer): int =