mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-24 09:50:24 +00:00
parent
aaa0f29540
commit
c767b3dc0c
2 changed files with 26 additions and 3 deletions
|
|
@ -211,7 +211,7 @@ func main() {
|
|||
case tcell.KeyCtrlQ:
|
||||
// Make sure not to quit if there are unsaved changes
|
||||
if helpOpen {
|
||||
view.buf = buf
|
||||
view.OpenBuffer(buf)
|
||||
helpOpen = false
|
||||
} else {
|
||||
if view.CanClose("Quit anyway? (yes, no, save) ") {
|
||||
|
|
@ -234,9 +234,9 @@ func main() {
|
|||
helpBuffer := NewBuffer(helpTxt, "")
|
||||
helpBuffer.name = "Help"
|
||||
helpOpen = true
|
||||
view.buf = helpBuffer
|
||||
view.OpenBuffer(helpBuffer)
|
||||
} else {
|
||||
view.buf = buf
|
||||
view.OpenBuffer(buf)
|
||||
helpOpen = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -276,6 +276,29 @@ func (v *View) SelectAll() {
|
|||
v.cursor.y = 0
|
||||
}
|
||||
|
||||
// OpenBuffer opens a new buffer in this view.
|
||||
// This resets the topline, event handler and cursor.
|
||||
func (v *View) OpenBuffer(buf *Buffer) {
|
||||
v.buf = buf
|
||||
v.topline = 0
|
||||
// Put the cursor at the first spot
|
||||
v.cursor = Cursor{
|
||||
x: 0,
|
||||
y: 0,
|
||||
v: v,
|
||||
}
|
||||
v.cursor.ResetSelection()
|
||||
|
||||
v.eh = NewEventHandler(v)
|
||||
|
||||
v.matches = Match(v)
|
||||
|
||||
// Set mouseReleased to true because we assume the mouse is not being pressed when
|
||||
// the editor is opened
|
||||
v.mouseReleased = true
|
||||
v.lastClickTime = time.Time{}
|
||||
}
|
||||
|
||||
// OpenFile opens a new file in the current view
|
||||
// It makes sure that the current buffer can be closed first (unsaved changes)
|
||||
func (v *View) OpenFile() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue