mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 22:50:21 +09:00
Open help in a separate split
This commit is contained in:
@@ -327,7 +327,7 @@ func (v *View) InsertTab() bool {
|
||||
|
||||
// Save the buffer to disk
|
||||
func (v *View) Save() bool {
|
||||
if v.helpOpen {
|
||||
if v.Help {
|
||||
// We can't save the help text
|
||||
return false
|
||||
}
|
||||
@@ -651,15 +651,13 @@ func (v *View) ClearStatus() bool {
|
||||
|
||||
// ToggleHelp toggles the help screen
|
||||
func (v *View) ToggleHelp() bool {
|
||||
if !v.helpOpen {
|
||||
v.lastBuffer = v.Buf
|
||||
if !CurView().Help {
|
||||
helpBuffer := NewBuffer([]byte(helpTxt), "help.md")
|
||||
helpBuffer.Name = "Help"
|
||||
v.helpOpen = true
|
||||
v.OpenBuffer(helpBuffer)
|
||||
v.HSplit(helpBuffer)
|
||||
CurView().Help = true
|
||||
} else {
|
||||
v.OpenBuffer(v.lastBuffer)
|
||||
v.helpOpen = false
|
||||
v.Quit()
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -688,9 +686,6 @@ func (v *View) CommandMode() bool {
|
||||
// is the last view
|
||||
// However, since micro only supports one view for now, it doesn't really matter
|
||||
func (v *View) Quit() bool {
|
||||
if v.helpOpen {
|
||||
return v.ToggleHelp()
|
||||
}
|
||||
// Make sure not to quit if there are unsaved changes
|
||||
if v.CanClose("Quit anyway? (yes, no, save) ") {
|
||||
v.CloseBuffer()
|
||||
|
||||
@@ -189,7 +189,6 @@ func (b *Buffer) Serialize() error {
|
||||
b.Cursor,
|
||||
b.ModTime,
|
||||
})
|
||||
// err = enc.Encode(b.Cursor)
|
||||
}
|
||||
file.Close()
|
||||
return err
|
||||
|
||||
@@ -37,7 +37,7 @@ func (sline *Statusline) Display() {
|
||||
file += " " + sline.view.Buf.FileType
|
||||
|
||||
rightText := helpBinding + " for help "
|
||||
if sline.view.helpOpen {
|
||||
if sline.view.Help {
|
||||
rightText = helpBinding + " to close help "
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ type View struct {
|
||||
widthPercent int
|
||||
heightPercent int
|
||||
|
||||
// Specifies whether or not this view holds a help buffer
|
||||
Help bool
|
||||
|
||||
// Actual with and height
|
||||
width int
|
||||
height int
|
||||
@@ -40,22 +43,13 @@ type View struct {
|
||||
// Holds the list of gutter messages
|
||||
messages map[string][]GutterMessage
|
||||
|
||||
// Is the help text opened in this view
|
||||
helpOpen bool
|
||||
|
||||
// This is the index of this view in the views array
|
||||
Num int
|
||||
// What tab is this view stored in
|
||||
TabNum int
|
||||
|
||||
// Is this view modifiable?
|
||||
Modifiable bool
|
||||
|
||||
// The buffer
|
||||
Buf *Buffer
|
||||
// This is the buffer that was last opened
|
||||
// This is used to open help, and then go back to the previously opened buffer
|
||||
lastBuffer *Buffer
|
||||
// The statusline
|
||||
sline Statusline
|
||||
|
||||
|
||||
Reference in New Issue
Block a user