mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-25 18:07:07 +09:00
Better support for fake cursor
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package display
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"unicode/utf8"
|
||||
|
||||
@@ -340,11 +339,10 @@ func (w *BufWindow) getStyle(style tcell.Style, bloc buffer.Loc, r rune) (tcell.
|
||||
|
||||
func (w *BufWindow) showCursor(x, y int, main bool) {
|
||||
if w.active {
|
||||
if main && runtime.GOOS != "windows" {
|
||||
screen.Screen.ShowCursor(x, y)
|
||||
if main {
|
||||
screen.ShowCursor(x, y)
|
||||
} else {
|
||||
r, _, _, _ := screen.Screen.GetContent(x, y)
|
||||
screen.Screen.SetContent(x, y, r, nil, config.DefStyle.Reverse(true))
|
||||
screen.ShowFakeCursor(x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -596,13 +594,7 @@ func (w *BufWindow) displayBuffer() {
|
||||
screen.Screen.SetContent(i+w.X, vloc.Y+w.Y, ' ', nil, curStyle)
|
||||
}
|
||||
|
||||
for _, c := range cursors {
|
||||
if c.X == bloc.X && c.Y == bloc.Y && !c.HasSelection() {
|
||||
w.showCursor(w.X+vloc.X, w.Y+vloc.Y, c.Num == 0)
|
||||
}
|
||||
}
|
||||
|
||||
draw(' ', curStyle, false)
|
||||
draw(' ', curStyle, true)
|
||||
|
||||
bloc.X = w.StartCol
|
||||
bloc.Y++
|
||||
|
||||
@@ -121,7 +121,7 @@ func (i *InfoWindow) displayBuffer() {
|
||||
totalwidth := blocX - nColsBeforeStart
|
||||
for len(line) > 0 {
|
||||
if activeC.X == blocX {
|
||||
screen.Screen.ShowCursor(vlocX, i.Y)
|
||||
screen.ShowCursor(vlocX, i.Y)
|
||||
}
|
||||
|
||||
r, size := utf8.DecodeRune(line)
|
||||
@@ -155,7 +155,7 @@ func (i *InfoWindow) displayBuffer() {
|
||||
}
|
||||
}
|
||||
if activeC.X == blocX {
|
||||
screen.Screen.ShowCursor(vlocX, i.Y)
|
||||
screen.ShowCursor(vlocX, i.Y)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,6 @@ func (w *TermWindow) Display() {
|
||||
}
|
||||
if w.State.CursorVisible() && w.active {
|
||||
curx, cury := w.State.Cursor()
|
||||
screen.Screen.ShowCursor(curx+w.X, cury+w.Y)
|
||||
screen.ShowCursor(curx+w.X, cury+w.Y)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/zyedidia/micro/internal/config"
|
||||
"github.com/zyedidia/micro/internal/util"
|
||||
"github.com/zyedidia/tcell"
|
||||
)
|
||||
|
||||
@@ -31,6 +32,19 @@ func Redraw() {
|
||||
DrawChan <- true
|
||||
}
|
||||
|
||||
func ShowFakeCursor(x, y int) {
|
||||
r, _, _, _ := Screen.GetContent(x, y)
|
||||
Screen.SetContent(x, y, r, nil, config.DefStyle.Reverse(true))
|
||||
}
|
||||
|
||||
func ShowCursor(x, y int) {
|
||||
if util.FakeCursor {
|
||||
ShowFakeCursor(x, y)
|
||||
} else {
|
||||
Screen.ShowCursor(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
// TempFini shuts the screen down temporarily
|
||||
func TempFini() bool {
|
||||
screenWasNil := Screen == nil
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -30,6 +31,9 @@ var (
|
||||
CompileDate = "Unknown"
|
||||
// Debug logging
|
||||
Debug = "ON"
|
||||
// FakeCursor is used to disable the terminal cursor and have micro
|
||||
// draw its own (enabled for windows consoles where the cursor is slow)
|
||||
FakeCursor = true
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -38,6 +42,10 @@ func init() {
|
||||
if err != nil {
|
||||
fmt.Println("Invalid version: ", Version, err)
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
FakeCursor = true
|
||||
}
|
||||
}
|
||||
|
||||
// SliceEnd returns a byte slice where the index is a rune index
|
||||
|
||||
Reference in New Issue
Block a user