mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-06 15:10:27 +09:00
Use terminal cursor for the base cursor
If all cursors fake then that breaks support for things like inserting japanese characters nicely, so fake cursors are now only used as extra cursors.
This commit is contained in:
@@ -153,7 +153,7 @@ func (m *Messenger) YesNoPrompt(prompt string) (bool, bool) {
|
||||
for {
|
||||
m.Clear()
|
||||
m.Display()
|
||||
ShowCursor(Count(m.message), h-1)
|
||||
screen.ShowCursor(Count(m.message), h-1)
|
||||
screen.Show()
|
||||
event := <-events
|
||||
|
||||
@@ -190,7 +190,7 @@ func (m *Messenger) LetterPrompt(prompt string, responses ...rune) (rune, bool)
|
||||
for {
|
||||
m.Clear()
|
||||
m.Display()
|
||||
ShowCursor(Count(m.message), h-1)
|
||||
screen.ShowCursor(Count(m.message), h-1)
|
||||
screen.Show()
|
||||
event := <-events
|
||||
|
||||
@@ -470,7 +470,7 @@ func (m *Messenger) Display() {
|
||||
}
|
||||
|
||||
if m.hasPrompt {
|
||||
ShowCursor(Count(m.message)+m.cursorx, h-1)
|
||||
screen.ShowCursor(Count(m.message)+m.cursorx, h-1)
|
||||
screen.Show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,12 +865,12 @@ func (v *View) DisplayView() {
|
||||
|
||||
screen.SetContent(xOffset+char.visualLoc.X, yOffset+char.visualLoc.Y, char.drawChar, nil, lineStyle)
|
||||
|
||||
for _, c := range v.Buf.cursors {
|
||||
for i, c := range v.Buf.cursors {
|
||||
v.Cursor = c
|
||||
if tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() &&
|
||||
v.Cursor.Y == char.realLoc.Y && v.Cursor.X == char.realLoc.X && !cursorSet {
|
||||
ShowCursor(xOffset+char.visualLoc.X, yOffset+char.visualLoc.Y)
|
||||
// cursorSet = true
|
||||
v.Cursor.Y == char.realLoc.Y && v.Cursor.X == char.realLoc.X && (!cursorSet || i != 0) {
|
||||
ShowMultiCursor(xOffset+char.visualLoc.X, yOffset+char.visualLoc.Y, i)
|
||||
cursorSet = true
|
||||
}
|
||||
}
|
||||
v.Cursor = &v.Buf.Cursor
|
||||
@@ -885,11 +885,11 @@ func (v *View) DisplayView() {
|
||||
var cx, cy int
|
||||
if lastChar != nil {
|
||||
lastX = xOffset + lastChar.visualLoc.X + lastChar.width
|
||||
for _, c := range v.Buf.cursors {
|
||||
for i, c := range v.Buf.cursors {
|
||||
v.Cursor = c
|
||||
if tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() &&
|
||||
v.Cursor.Y == lastChar.realLoc.Y && v.Cursor.X == lastChar.realLoc.X+1 {
|
||||
ShowCursor(lastX, yOffset+lastChar.visualLoc.Y)
|
||||
ShowMultiCursor(lastX, yOffset+lastChar.visualLoc.Y, i)
|
||||
cx, cy = lastX, yOffset+lastChar.visualLoc.Y
|
||||
}
|
||||
}
|
||||
@@ -897,11 +897,11 @@ func (v *View) DisplayView() {
|
||||
realLoc = Loc{lastChar.realLoc.X + 1, realLineN}
|
||||
visualLoc = Loc{lastX - xOffset, lastChar.visualLoc.Y}
|
||||
} else if len(line) == 0 {
|
||||
for _, c := range v.Buf.cursors {
|
||||
for i, c := range v.Buf.cursors {
|
||||
v.Cursor = c
|
||||
if tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() &&
|
||||
v.Cursor.Y == realLineN {
|
||||
ShowCursor(xOffset, yOffset+visualLineN)
|
||||
ShowMultiCursor(xOffset, yOffset+visualLineN, i)
|
||||
cx, cy = xOffset, yOffset+visualLineN
|
||||
}
|
||||
}
|
||||
@@ -947,9 +947,13 @@ func (v *View) DisplayView() {
|
||||
}
|
||||
}
|
||||
|
||||
func ShowCursor(x, y int) {
|
||||
r, _, _, _ := screen.GetContent(x, y)
|
||||
screen.SetContent(x, y, r, nil, defStyle.Reverse(true))
|
||||
func ShowMultiCursor(x, y, i int) {
|
||||
if i == 0 {
|
||||
screen.ShowCursor(x, y)
|
||||
} else {
|
||||
r, _, _, _ := screen.GetContent(x, y)
|
||||
screen.SetContent(x, y, r, nil, defStyle.Reverse(true))
|
||||
}
|
||||
}
|
||||
|
||||
// Display renders the view, the cursor, and statusline
|
||||
|
||||
Reference in New Issue
Block a user