mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 14:47:16 +09:00
@@ -211,7 +211,7 @@ func main() {
|
|||||||
case tcell.KeyCtrlQ:
|
case tcell.KeyCtrlQ:
|
||||||
// Make sure not to quit if there are unsaved changes
|
// Make sure not to quit if there are unsaved changes
|
||||||
if helpOpen {
|
if helpOpen {
|
||||||
view.buf = buf
|
view.OpenBuffer(buf)
|
||||||
helpOpen = false
|
helpOpen = false
|
||||||
} else {
|
} else {
|
||||||
if view.CanClose("Quit anyway? (yes, no, save) ") {
|
if view.CanClose("Quit anyway? (yes, no, save) ") {
|
||||||
@@ -234,9 +234,9 @@ func main() {
|
|||||||
helpBuffer := NewBuffer(helpTxt, "")
|
helpBuffer := NewBuffer(helpTxt, "")
|
||||||
helpBuffer.name = "Help"
|
helpBuffer.name = "Help"
|
||||||
helpOpen = true
|
helpOpen = true
|
||||||
view.buf = helpBuffer
|
view.OpenBuffer(helpBuffer)
|
||||||
} else {
|
} else {
|
||||||
view.buf = buf
|
view.OpenBuffer(buf)
|
||||||
helpOpen = false
|
helpOpen = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,6 +276,29 @@ func (v *View) SelectAll() {
|
|||||||
v.cursor.y = 0
|
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
|
// OpenFile opens a new file in the current view
|
||||||
// It makes sure that the current buffer can be closed first (unsaved changes)
|
// It makes sure that the current buffer can be closed first (unsaved changes)
|
||||||
func (v *View) OpenFile() {
|
func (v *View) OpenFile() {
|
||||||
|
|||||||
Reference in New Issue
Block a user