]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/view.go
Fix some issues with unicode handling
[micro.git] / cmd / micro / view.go
index 91117b900dffd87f7bd5b4c36ff2cb8ef8564797..4080fa1642dd2f109cf73b3fae3259b828942c1f 100644 (file)
@@ -170,7 +170,7 @@ func (v *View) CanClose(msg string) bool {
                        if strings.ToLower(quit) == "yes" || strings.ToLower(quit) == "y" {
                                return true
                        } else if strings.ToLower(quit) == "save" || strings.ToLower(quit) == "s" {
-                               v.Save()
+                               v.Save(true)
                                return true
                        }
                }
@@ -330,7 +330,7 @@ func (v *View) HandleEvent(event tcell.Event) {
                                        if e.Modifiers() == key.modifiers {
                                                relocate = false
                                                for _, action := range actions {
-                                                       relocate = action(v) || relocate
+                                                       relocate = action(v, true) || relocate
                                                }
                                        }
                                }
@@ -466,10 +466,16 @@ func (v *View) ClearAllGutterMessages() {
 
 // Opens the given help page in a new horizontal split
 func (v *View) openHelp(helpPage string) {
-       helpBuffer := NewBuffer([]byte(helpPages[helpPage]), helpPage+".md")
-       helpBuffer.Name = "Help"
-       v.HSplit(helpBuffer)
-       CurView().Help = true
+       if v.Help {
+               helpBuffer := NewBuffer([]byte(helpPages[helpPage]), helpPage+".md")
+               helpBuffer.Name = "Help"
+               v.OpenBuffer(helpBuffer)
+       } else {
+               helpBuffer := NewBuffer([]byte(helpPages[helpPage]), helpPage+".md")
+               helpBuffer.Name = "Help"
+               v.HSplit(helpBuffer)
+               CurView().Help = true
+       }
 }
 
 func (v *View) drawCell(x, y int, ch rune, combc []rune, style tcell.Style) {
@@ -618,7 +624,8 @@ func (v *View) DisplayView() {
                }
 
                // Now we actually draw the line
-               for colN, ch := range line {
+               colN := 0
+               for _, ch := range line {
                        lineStyle := defStyle
 
                        if settings["syntax"].(bool) {
@@ -703,6 +710,7 @@ func (v *View) DisplayView() {
                        }
                        charNum = charNum.Move(1, v.Buf)
                        screenX++
+                       colN++
                }
                // Here we are at a newline