fix ctrl+down
This commit is contained in:
parent
2452633e32
commit
4323e5872c
|
@ -25,6 +25,7 @@ proc render*(textBuffer: TextBuffer, termBuffer: Buffer, prompt: string, scroll:
|
||||||
|
|
||||||
if bufWidth != termWidth or bufHeight != min(lineCount, termHeight):
|
if bufWidth != termWidth or bufHeight != min(lineCount, termHeight):
|
||||||
termBuffer.resize(termWidth, min(lineCount, termHeight))
|
termBuffer.resize(termWidth, min(lineCount, termHeight))
|
||||||
|
|
||||||
|
|
||||||
termBuffer.clear()
|
termBuffer.clear()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import unicode
|
import unicode
|
||||||
import escapeSequences
|
import escapeSequences
|
||||||
import sequtils
|
import sequtils
|
||||||
|
import strformat
|
||||||
|
|
||||||
type
|
type
|
||||||
Buffer* = ref object
|
Buffer* = ref object
|
||||||
|
@ -47,7 +48,7 @@ func getCursorPos*(buf: Buffer): (int, int) =
|
||||||
|
|
||||||
proc setCursorPos*(buf: Buffer, x, y: int) =
|
proc setCursorPos*(buf: Buffer, x, y: int) =
|
||||||
if x < 0 or y < 0 or x >= buf.width or y >= buf.height:
|
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.bufferX = x
|
||||||
buf.bufferY = y
|
buf.bufferY = y
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,9 @@ proc enter*(buf: TextBuffer) =
|
||||||
proc newLine*(buf: TextBuffer) =
|
proc newLine*(buf: TextBuffer) =
|
||||||
# inserts a new empty line below the current one
|
# inserts a new empty line below the current one
|
||||||
# and moves cursor to it
|
# and moves cursor to it
|
||||||
# TODO fix crash
|
|
||||||
inc buf.cursorY
|
inc buf.cursorY
|
||||||
buf.content.insert(@[], buf.cursorY)
|
let empty: seq[Rune] = @[]
|
||||||
|
buf.content.insert(empty, buf.cursorY)
|
||||||
buf.cursorX = 0
|
buf.cursorX = 0
|
||||||
|
|
||||||
proc getLineCount*(buf: TextBuffer): int =
|
proc getLineCount*(buf: TextBuffer): int =
|
||||||
|
|
Loading…
Reference in New Issue