h.SetView(v)
}
-// If the user has scrolled past the last line, ScrollAdjust can be used
-// to shift the view so that the last line is at the bottom
+// ScrollAdjust can be used to shift the view so that the last line is at the
+// bottom if the user has scrolled past the last line.
func (h *BufPane) ScrollAdjust() {
v := h.GetView()
end := h.SLocFromLoc(h.Buf.End())
return true
}
-// Copy the current line to the clipboard
+// CopyLine copies the current line to the clipboard
func (h *BufPane) CopyLine() bool {
if h.Cursor.HasSelection() {
return false
- } else {
- h.Cursor.SelectLine()
- h.Cursor.CopySelection(clipboard.ClipboardReg)
- h.freshClip = true
- InfoBar.Message("Copied line")
}
+ h.Cursor.SelectLine()
+ h.Cursor.CopySelection(clipboard.ClipboardReg)
+ h.freshClip = true
+ InfoBar.Message("Copied line")
+
h.Cursor.Deselect(true)
h.Relocate()
return true
h.Relocate()
return true
- } else {
- return h.CutLine()
}
+ return h.CutLine()
}
// DuplicateLine duplicates the current line or selection
}
var curmacro []interface{}
-var recording_macro bool
+var recordingMacro bool
// ToggleMacro toggles recording of a macro
func (h *BufPane) ToggleMacro() bool {
- recording_macro = !recording_macro
- if recording_macro {
+ recordingMacro = !recordingMacro
+ if recordingMacro {
curmacro = []interface{}{}
InfoBar.Message("Recording")
} else {
// PlayMacro plays back the most recently recorded macro
func (h *BufPane) PlayMacro() bool {
- if recording_macro {
+ if recordingMacro {
return false
}
for _, action := range curmacro {
func (h *BufPane) SpawnMultiCursorUp() bool {
if h.Cursor.Y == 0 {
return false
- } else {
- h.Cursor.GotoLoc(buffer.Loc{h.Cursor.X, h.Cursor.Y - 1})
- h.Cursor.Relocate()
}
+ h.Cursor.GotoLoc(buffer.Loc{h.Cursor.X, h.Cursor.Y - 1})
+ h.Cursor.Relocate()
c := buffer.NewCursor(h.Buf, buffer.Loc{h.Cursor.X, h.Cursor.Y + 1})
h.Buf.AddCursor(c)
func (h *BufPane) SpawnMultiCursorDown() bool {
if h.Cursor.Y+1 == h.Buf.LinesNum() {
return false
- } else {
- h.Cursor.GotoLoc(buffer.Loc{h.Cursor.X, h.Cursor.Y + 1})
- h.Cursor.Relocate()
}
+ h.Cursor.GotoLoc(buffer.Loc{h.Cursor.X, h.Cursor.Y + 1})
+ h.Cursor.Relocate()
c := buffer.NewCursor(h.Buf, buffer.Loc{h.Cursor.X, h.Cursor.Y - 1})
h.Buf.AddCursor(c)
"github.com/zyedidia/tcell/v2"
)
-// Micro's default style
+// DefStyle is Micro's default style
var DefStyle tcell.Style = tcell.StyleDefault
-// The current colorscheme
+// Colorscheme is the current colorscheme
var Colorscheme map[string]tcell.Style
// GetColor takes in a syntax group and returns the colorscheme's style for that group
"github.com/zyedidia/tcell/v2"
)
-// The BufWindow provides a way of displaying a certain section
-// of a buffer
+// The BufWindow provides a way of displaying a certain section of a buffer.
type BufWindow struct {
*View
return w
}
+// SetBuffer sets this window's buffer.
func (w *BufWindow) SetBuffer(b *buffer.Buffer) {
w.Buf = b
b.OptionCallback = func(option string, nativeValue interface{}) {
}
}
+// GetView gets the view.
func (w *BufWindow) GetView() *View {
return w.View
}
+// GetView sets the view.
func (w *BufWindow) SetView(view *View) {
w.View = view
}
+// Resize resizes this window.
func (w *BufWindow) Resize(width, height int) {
w.Width, w.Height = width, height
w.updateDisplayInfo()
}
}
+// SetActive marks the window as active.
func (w *BufWindow) SetActive(b bool) {
w.active = b
}
+// IsActive returns true if this window is active.
func (w *BufWindow) IsActive() bool {
return w.active
}