From a99601668a701ec8ba27dae3d798bac9bc2f5a9e Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 7 Jan 2017 18:02:14 +0300 Subject: [PATCH] disable buggy cursor move in windows --- ui.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ui.go b/ui.go index b3856f9..4d3afd6 100644 --- a/ui.go +++ b/ui.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "sort" "strconv" "strings" @@ -497,6 +498,14 @@ func (ui *ui) loadFile(nav *nav) { } } +func moveCursor(y, x int) { + // TODO: implement for windows + if runtime.GOOS == "windows" { + return + } + fmt.Printf("\033[%d;%dH", y, x) +} + func (ui *ui) draw(nav *nav) { fg, bg := termbox.ColorDefault, termbox.ColorDefault @@ -566,7 +575,7 @@ func (ui *ui) draw(nav *nav) { if ui.cmdpref == "" { // leave the cursor at the beginning of the current file for screen readers - fmt.Printf("\033[%d;%dH", ui.wins[woff+length-1].y+nav.dirs[doff+length-1].pos+1, ui.wins[woff+length-1].x+1) + moveCursor(ui.wins[woff+length-1].y+nav.dirs[doff+length-1].pos+1, ui.wins[woff+length-1].x+1) } }