mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-18 23:05:40 -04:00
More style improvements
This commit is contained in:
parent
c44ccb8cc7
commit
3a97ce820c
@ -34,8 +34,8 @@ func (h *BufPane) ScrollDown(n int) {
|
|||||||
h.SetView(v)
|
h.SetView(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user has scrolled past the last line, ScrollAdjust can be used
|
// ScrollAdjust can be used to shift the view so that the last line is at the
|
||||||
// to shift the view so that the last line is at the bottom
|
// bottom if the user has scrolled past the last line.
|
||||||
func (h *BufPane) ScrollAdjust() {
|
func (h *BufPane) ScrollAdjust() {
|
||||||
v := h.GetView()
|
v := h.GetView()
|
||||||
end := h.SLocFromLoc(h.Buf.End())
|
end := h.SLocFromLoc(h.Buf.End())
|
||||||
@ -1025,16 +1025,16 @@ func (h *BufPane) Copy() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the current line to the clipboard
|
// CopyLine copies the current line to the clipboard
|
||||||
func (h *BufPane) CopyLine() bool {
|
func (h *BufPane) CopyLine() bool {
|
||||||
if h.Cursor.HasSelection() {
|
if h.Cursor.HasSelection() {
|
||||||
return false
|
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.Cursor.Deselect(true)
|
||||||
h.Relocate()
|
h.Relocate()
|
||||||
return true
|
return true
|
||||||
@ -1077,9 +1077,8 @@ func (h *BufPane) Cut() bool {
|
|||||||
|
|
||||||
h.Relocate()
|
h.Relocate()
|
||||||
return true
|
return true
|
||||||
} else {
|
|
||||||
return h.CutLine()
|
|
||||||
}
|
}
|
||||||
|
return h.CutLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
// DuplicateLine duplicates the current line or selection
|
// DuplicateLine duplicates the current line or selection
|
||||||
@ -1638,12 +1637,12 @@ func (h *BufPane) PreviousSplit() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var curmacro []interface{}
|
var curmacro []interface{}
|
||||||
var recording_macro bool
|
var recordingMacro bool
|
||||||
|
|
||||||
// ToggleMacro toggles recording of a macro
|
// ToggleMacro toggles recording of a macro
|
||||||
func (h *BufPane) ToggleMacro() bool {
|
func (h *BufPane) ToggleMacro() bool {
|
||||||
recording_macro = !recording_macro
|
recordingMacro = !recordingMacro
|
||||||
if recording_macro {
|
if recordingMacro {
|
||||||
curmacro = []interface{}{}
|
curmacro = []interface{}{}
|
||||||
InfoBar.Message("Recording")
|
InfoBar.Message("Recording")
|
||||||
} else {
|
} else {
|
||||||
@ -1655,7 +1654,7 @@ func (h *BufPane) ToggleMacro() bool {
|
|||||||
|
|
||||||
// PlayMacro plays back the most recently recorded macro
|
// PlayMacro plays back the most recently recorded macro
|
||||||
func (h *BufPane) PlayMacro() bool {
|
func (h *BufPane) PlayMacro() bool {
|
||||||
if recording_macro {
|
if recordingMacro {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, action := range curmacro {
|
for _, action := range curmacro {
|
||||||
@ -1715,10 +1714,9 @@ func (h *BufPane) SpawnMultiCursor() bool {
|
|||||||
func (h *BufPane) SpawnMultiCursorUp() bool {
|
func (h *BufPane) SpawnMultiCursorUp() bool {
|
||||||
if h.Cursor.Y == 0 {
|
if h.Cursor.Y == 0 {
|
||||||
return false
|
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})
|
c := buffer.NewCursor(h.Buf, buffer.Loc{h.Cursor.X, h.Cursor.Y + 1})
|
||||||
h.Buf.AddCursor(c)
|
h.Buf.AddCursor(c)
|
||||||
@ -1733,10 +1731,9 @@ func (h *BufPane) SpawnMultiCursorUp() bool {
|
|||||||
func (h *BufPane) SpawnMultiCursorDown() bool {
|
func (h *BufPane) SpawnMultiCursorDown() bool {
|
||||||
if h.Cursor.Y+1 == h.Buf.LinesNum() {
|
if h.Cursor.Y+1 == h.Buf.LinesNum() {
|
||||||
return false
|
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})
|
c := buffer.NewCursor(h.Buf, buffer.Loc{h.Cursor.X, h.Cursor.Y - 1})
|
||||||
h.Buf.AddCursor(c)
|
h.Buf.AddCursor(c)
|
||||||
|
@ -470,7 +470,7 @@ func (h *BufPane) execAction(action func(*BufPane) bool, name string, cursor int
|
|||||||
success = success && h.PluginCB("on"+name)
|
success = success && h.PluginCB("on"+name)
|
||||||
|
|
||||||
if isMulti {
|
if isMulti {
|
||||||
if recording_macro {
|
if recordingMacro {
|
||||||
if name != "ToggleMacro" && name != "PlayMacro" {
|
if name != "ToggleMacro" && name != "PlayMacro" {
|
||||||
curmacro = append(curmacro, action)
|
curmacro = append(curmacro, action)
|
||||||
}
|
}
|
||||||
@ -542,7 +542,7 @@ func (h *BufPane) DoRuneInsert(r rune) {
|
|||||||
} else {
|
} else {
|
||||||
h.Buf.Insert(c.Loc, string(r))
|
h.Buf.Insert(c.Loc, string(r))
|
||||||
}
|
}
|
||||||
if recording_macro {
|
if recordingMacro {
|
||||||
curmacro = append(curmacro, r)
|
curmacro = append(curmacro, r)
|
||||||
}
|
}
|
||||||
h.Relocate()
|
h.Relocate()
|
||||||
|
@ -229,7 +229,7 @@ func (k *KeyTree) ResetEvents() {
|
|||||||
k.cursor.mouseInfo = nil
|
k.cursor.mouseInfo = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CurrentEventsStr returns the list of recorded events as a string
|
// RecordedEventsStr returns the list of recorded events as a string
|
||||||
func (k *KeyTree) RecordedEventsStr() string {
|
func (k *KeyTree) RecordedEventsStr() string {
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
for _, e := range k.cursor.recordedEvents {
|
for _, e := range k.cursor.recordedEvents {
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/zyedidia/micro/v2/internal/display"
|
"github.com/zyedidia/micro/v2/internal/display"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// A Pane is a general interface for a window in the editor.
|
||||||
type Pane interface {
|
type Pane interface {
|
||||||
Handler
|
Handler
|
||||||
display.Window
|
display.Window
|
||||||
|
@ -9,10 +9,10 @@ import (
|
|||||||
"github.com/zyedidia/tcell/v2"
|
"github.com/zyedidia/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Micro's default style
|
// DefStyle is Micro's default style
|
||||||
var DefStyle tcell.Style = tcell.StyleDefault
|
var DefStyle tcell.Style = tcell.StyleDefault
|
||||||
|
|
||||||
// The current colorscheme
|
// Colorscheme is the current colorscheme
|
||||||
var Colorscheme map[string]tcell.Style
|
var Colorscheme map[string]tcell.Style
|
||||||
|
|
||||||
// GetColor takes in a syntax group and returns the colorscheme's style for that group
|
// GetColor takes in a syntax group and returns the colorscheme's style for that group
|
||||||
|
@ -11,8 +11,7 @@ import (
|
|||||||
"github.com/zyedidia/tcell/v2"
|
"github.com/zyedidia/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The BufWindow provides a way of displaying a certain section
|
// The BufWindow provides a way of displaying a certain section of a buffer.
|
||||||
// of a buffer
|
|
||||||
type BufWindow struct {
|
type BufWindow struct {
|
||||||
*View
|
*View
|
||||||
|
|
||||||
@ -44,6 +43,7 @@ func NewBufWindow(x, y, width, height int, buf *buffer.Buffer) *BufWindow {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetBuffer sets this window's buffer.
|
||||||
func (w *BufWindow) SetBuffer(b *buffer.Buffer) {
|
func (w *BufWindow) SetBuffer(b *buffer.Buffer) {
|
||||||
w.Buf = b
|
w.Buf = b
|
||||||
b.OptionCallback = func(option string, nativeValue interface{}) {
|
b.OptionCallback = func(option string, nativeValue interface{}) {
|
||||||
@ -65,14 +65,17 @@ func (w *BufWindow) SetBuffer(b *buffer.Buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetView gets the view.
|
||||||
func (w *BufWindow) GetView() *View {
|
func (w *BufWindow) GetView() *View {
|
||||||
return w.View
|
return w.View
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetView sets the view.
|
||||||
func (w *BufWindow) SetView(view *View) {
|
func (w *BufWindow) SetView(view *View) {
|
||||||
w.View = view
|
w.View = view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resize resizes this window.
|
||||||
func (w *BufWindow) Resize(width, height int) {
|
func (w *BufWindow) Resize(width, height int) {
|
||||||
w.Width, w.Height = width, height
|
w.Width, w.Height = width, height
|
||||||
w.updateDisplayInfo()
|
w.updateDisplayInfo()
|
||||||
@ -86,10 +89,12 @@ func (w *BufWindow) Resize(width, height int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetActive marks the window as active.
|
||||||
func (w *BufWindow) SetActive(b bool) {
|
func (w *BufWindow) SetActive(b bool) {
|
||||||
w.active = b
|
w.active = b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsActive returns true if this window is active.
|
||||||
func (w *BufWindow) IsActive() bool {
|
func (w *BufWindow) IsActive() bool {
|
||||||
return w.active
|
return w.active
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ func combineLineMatch(src, dst LineMatch) LineMatch {
|
|||||||
// A State represents the region at the end of a line
|
// A State represents the region at the end of a line
|
||||||
type State *region
|
type State *region
|
||||||
|
|
||||||
|
// EmptyDef is an empty definition.
|
||||||
var EmptyDef = Def{nil, &rules{}}
|
var EmptyDef = Def{nil, &rules{}}
|
||||||
|
|
||||||
// LineStates is an interface for a buffer-like object which can also store the states and matches for every line
|
// LineStates is an interface for a buffer-like object which can also store the states and matches for every line
|
||||||
|
Loading…
Reference in New Issue
Block a user