mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-19 15:27:20 +09:00
@@ -309,6 +309,16 @@ func (v *View) Delete() bool {
|
||||
func (v *View) InsertTab() bool {
|
||||
// Insert a tab
|
||||
if v.Cursor.HasSelection() {
|
||||
if v.Cursor.CurSelection[0].Y != v.Cursor.CurSelection[1].Y {
|
||||
for i := v.Cursor.CurSelection[0].Y; i <= v.Cursor.CurSelection[1].Y; i++ {
|
||||
if settings["tabstospaces"].(bool) {
|
||||
v.Buf.Insert(Loc{0, i}, Spaces(int(settings["tabsize"].(float64))))
|
||||
} else {
|
||||
v.Buf.Insert(Loc{0, i}, "\t")
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
v.Cursor.DeleteSelection()
|
||||
v.Cursor.ResetSelection()
|
||||
}
|
||||
|
||||
@@ -293,7 +293,6 @@ func (c *Cursor) Start() {
|
||||
func (c *Cursor) GetCharPosInLine(lineNum, visualPos int) int {
|
||||
// Get the tab size
|
||||
tabSize := int(settings["tabsize"].(float64))
|
||||
// This is the visual line -- every \t replaced with the correct number of spaces
|
||||
visualLineLen := StringWidth(c.buf.Line(lineNum))
|
||||
if visualPos > visualLineLen {
|
||||
visualPos = visualLineLen
|
||||
|
||||
Reference in New Issue
Block a user