todo.txt
test.txt
log.txt
+*.old
# Builds the runtime
runtime:
go get -u github.com/jteeuwen/go-bindata/...
- $(GOBIN)/go-bindata -nometadata -o runtime.go runtime/...
- mv runtime.go cmd/micro
- gofmt -w cmd/micro/runtime.go
+ $(GOBIN)/go-bindata -pkg config -nomemcopy -nometadata -o runtime.go runtime/...
+ mv runtime.go cmd/micro/config
+ gofmt -w cmd/micro/config/runtime.go
test:
go test ./cmd/micro
// CursorUp moves the cursor up
func (a *BufActionHandler) CursorUp() bool {
+ a.Cursor.Deselect(true)
+ a.Cursor.Up()
return true
}
// CursorDown moves the cursor down
func (a *BufActionHandler) CursorDown() bool {
+ a.Cursor.Deselect(true)
+ a.Cursor.Down()
return true
}
// CursorLeft moves the cursor left
func (a *BufActionHandler) CursorLeft() bool {
+ a.Cursor.Deselect(true)
+ a.Cursor.Left()
return true
}
// CursorRight moves the cursor right
func (a *BufActionHandler) CursorRight() bool {
+ a.Cursor.Deselect(true)
+ a.Cursor.Right()
return true
}
Buf: buf,
Loc: buf.StartCursor,
}}
+ a.Cursor = a.cursors[0]
buf.SetCursors(a.cursors)
return a
// the current cursor its selection too
func (c *Cursor) GotoLoc(l Loc) {
c.X, c.Y = l.X, l.Y
- c.LastVisualX = c.GetVisualX()
+ c.StoreVisualX()
}
// GetVisualX returns the x value of the cursor in visual spaces
width += runewidth.RuneWidth(r)
}
- i++
-
if width >= visualPos {
+ if width == visualPos {
+ i++
+ }
break
}
+ i++
}
return i
}
}
+// Deselect closes the cursor's current selection
+// Start indicates whether the cursor should be placed
+// at the start or end of the selection
+func (c *Cursor) Deselect(start bool) {
+ if c.HasSelection() {
+ if start {
+ c.Loc = c.CurSelection[0]
+ } else {
+ c.Loc = c.CurSelection[1]
+ }
+ c.ResetSelection()
+ c.StoreVisualX()
+ }
+}
+
// GetSelection returns the cursor's selection
func (c *Cursor) GetSelection() []byte {
if InBounds(c.CurSelection[0], c.Buf) && InBounds(c.CurSelection[1], c.Buf) {
c.Up()
c.End()
}
- c.LastVisualX = c.GetVisualX()
+ c.StoreVisualX()
}
// Right moves the cursor right one cell (if possible) or
c.Down()
c.Start()
}
- c.LastVisualX = c.GetVisualX()
+ c.StoreVisualX()
}
// Relocate makes sure that the cursor is inside the bounds
c.X = utf8.RuneCount(c.Buf.LineBytes(c.Y))
}
}
+
+func (c *Cursor) StoreVisualX() {
+ c.LastVisualX = c.GetVisualX()
+}
for {
// Display everything
- w.Clear()
+ screen.Screen.Fill(' ', config.DefStyle)
w.DisplayBuffer()
w.DisplayStatusLine()
screen.Screen.Show()
Screen, err = tcell.NewScreen()
if err != nil {
fmt.Println(err)
- fmt.Println("Fatal: Micro could not initialize a screen.")
+ fmt.Println("Fatal: Micro could not initialize a Screen.")
os.Exit(1)
}
} else {
fmt.Println(err)
- fmt.Println("Fatal: Micro could not initialize a screen.")
+ fmt.Println("Fatal: Micro could not initialize a Screen.")
os.Exit(1)
}
}
}
os.Setenv("TCELLDB", tcelldb)
+
+ // Screen.SetStyle(defStyle)
}
// NewStatusLine returns a statusline bound to a window
func NewStatusLine(win *Window) *StatusLine {
s := new(StatusLine)
- // s.FormatLeft = "$(filename) $(modified)($(line),$(col)) $(opt:filetype) $(opt:fileformat)"
- s.FormatLeft = "$(filename) $(modified)(line,col) $(opt:filetype) $(opt:fileformat)"
+ s.FormatLeft = "$(filename) $(modified)($(line),$(col)) $(opt:filetype) $(opt:fileformat)"
+ // s.FormatLeft = "$(filename) $(modified)(line,col) $(opt:filetype) $(opt:fileformat)"
s.FormatRight = "$(bind:ToggleKeyMenu): show bindings, $(bind:ToggleHelp): open help"
s.Info = map[string]func(*buffer.Buffer) string{
"filename": func(b *buffer.Buffer) string {
return b.GetName()
},
"line": func(b *buffer.Buffer) string {
- return strconv.Itoa(b.GetActiveCursor().Y)
+ return strconv.Itoa(b.GetActiveCursor().Y + 1)
},
"col": func(b *buffer.Buffer) string {
- return strconv.Itoa(b.GetActiveCursor().X)
+ return strconv.Itoa(b.GetActiveCursor().X + 1)
},
"modified": func(b *buffer.Buffer) string {
if b.Modified() {
return style
}
+func (w *Window) ShowCursor(x, y int, main bool) {
+ if main {
+ screen.Screen.ShowCursor(x, y)
+ } else {
+ r, _, _, _ := screen.Screen.GetContent(x, y)
+ screen.Screen.SetContent(x, y, r, nil, config.DefStyle.Reverse(true))
+ }
+}
+
// DisplayBuffer draws the buffer being shown in this window on the screen.Screen
func (w *Window) DisplayBuffer() {
b := w.Buf
line, nColsBeforeStart := util.SliceVisualEnd(line, bloc.X, tabsize)
totalwidth := bloc.X - nColsBeforeStart
for len(line) > 0 {
+ if w.Buf.GetActiveCursor().X == bloc.X && w.Buf.GetActiveCursor().Y == bloc.Y {
+ w.ShowCursor(vloc.X, vloc.Y, true)
+ }
+
r, size := utf8.DecodeRune(line)
curStyle = w.GetStyle(curStyle, bloc, r)
}
}
}
+ if w.Buf.GetActiveCursor().X == bloc.X && w.Buf.GetActiveCursor().Y == bloc.Y {
+ w.ShowCursor(vloc.X, vloc.Y, true)
+ }
bloc.X = w.StartCol
bloc.Y++
if bloc.Y >= b.LinesNum() {