mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-10 06:40:24 +09:00
Fix empty splits and single terms
This commit is contained in:
@@ -1065,16 +1065,16 @@ func (h *BufHandler) NextTab() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// VSplitBinding opens an empty vertical split
|
||||
func (h *BufHandler) VSplitBinding() bool {
|
||||
h.vsplit(buffer.NewBufferFromString("", "", buffer.BTDefault))
|
||||
// VSplitAction opens an empty vertical split
|
||||
func (h *BufHandler) VSplitAction() bool {
|
||||
h.VSplitBuf(buffer.NewBufferFromString("", "", buffer.BTDefault))
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// HSplitBinding opens an empty horizontal split
|
||||
func (h *BufHandler) HSplitBinding() bool {
|
||||
h.hsplit(buffer.NewBufferFromString("", "", buffer.BTDefault))
|
||||
// HSplitAction opens an empty horizontal split
|
||||
func (h *BufHandler) HSplitAction() bool {
|
||||
h.HSplitBuf(buffer.NewBufferFromString("", "", buffer.BTDefault))
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
package action
|
||||
|
||||
func (*BufHandler) Suspend() bool {
|
||||
// TODO: error message
|
||||
InfoBar.Error("Suspend is only supported on BSD/Linux")
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -254,14 +254,14 @@ func (h *BufHandler) DoRuneInsert(r rune) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *BufHandler) vsplit(buf *buffer.Buffer) {
|
||||
func (h *BufHandler) VSplitBuf(buf *buffer.Buffer) {
|
||||
e := NewBufEditPane(0, 0, 0, 0, buf)
|
||||
e.splitID = MainTab().GetNode(h.splitID).VSplit(h.Buf.Settings["splitright"].(bool))
|
||||
MainTab().Panes = append(MainTab().Panes, e)
|
||||
MainTab().Resize()
|
||||
MainTab().SetActive(len(MainTab().Panes) - 1)
|
||||
}
|
||||
func (h *BufHandler) hsplit(buf *buffer.Buffer) {
|
||||
func (h *BufHandler) HSplitBuf(buf *buffer.Buffer) {
|
||||
e := NewBufEditPane(0, 0, 0, 0, buf)
|
||||
e.splitID = MainTab().GetNode(h.splitID).HSplit(h.Buf.Settings["splitbottom"].(bool))
|
||||
MainTab().Panes = append(MainTab().Panes, e)
|
||||
@@ -350,8 +350,8 @@ var BufKeyActions = map[string]BufKeyAction{
|
||||
"NextSplit": (*BufHandler).NextSplit,
|
||||
"PreviousSplit": (*BufHandler).PreviousSplit,
|
||||
"Unsplit": (*BufHandler).Unsplit,
|
||||
"VSplit": (*BufHandler).VSplitBinding,
|
||||
"HSplit": (*BufHandler).HSplitBinding,
|
||||
"VSplit": (*BufHandler).VSplitAction,
|
||||
"HSplit": (*BufHandler).HSplitAction,
|
||||
"ToggleMacro": (*BufHandler).ToggleMacro,
|
||||
"PlayMacro": (*BufHandler).PlayMacro,
|
||||
"Suspend": (*BufHandler).Suspend,
|
||||
|
||||
@@ -198,25 +198,37 @@ func (h *BufHandler) HelpCmd(args []string) {
|
||||
// VSplitCmd opens a vertical split with file given in the first argument
|
||||
// If no file is given, it opens an empty buffer in a new split
|
||||
func (h *BufHandler) VSplitCmd(args []string) {
|
||||
if len(args) == 0 {
|
||||
// Open an empty vertical split
|
||||
h.VSplitAction()
|
||||
return
|
||||
}
|
||||
|
||||
buf, err := buffer.NewBufferFromFile(args[0], buffer.BTDefault)
|
||||
if err != nil {
|
||||
InfoBar.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
h.vsplit(buf)
|
||||
h.VSplitBuf(buf)
|
||||
}
|
||||
|
||||
// HSplitCmd opens a horizontal split with file given in the first argument
|
||||
// If no file is given, it opens an empty buffer in a new split
|
||||
func (h *BufHandler) HSplitCmd(args []string) {
|
||||
if len(args) == 0 {
|
||||
// Open an empty horizontal split
|
||||
h.HSplitAction()
|
||||
return
|
||||
}
|
||||
|
||||
buf, err := buffer.NewBufferFromFile(args[0], buffer.BTDefault)
|
||||
if err != nil {
|
||||
InfoBar.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
h.hsplit(buf)
|
||||
h.HSplitBuf(buf)
|
||||
}
|
||||
|
||||
// EvalCmd evaluates a lua expression
|
||||
@@ -318,10 +330,21 @@ func (h *BufHandler) TermCmd(args []string) {
|
||||
}
|
||||
|
||||
term := func(i int) {
|
||||
v := h.GetView()
|
||||
// If there is only one open file we make a new tab instead of overwriting it
|
||||
newtab := len(MainTab().Panes) == 1 && len(Tabs.List) == 1
|
||||
|
||||
t := new(shell.Terminal)
|
||||
t.Start(args, false, true)
|
||||
MainTab().Panes[i] = NewTermHandler(v.X, v.Y, v.Width, v.Height, t, h.ID())
|
||||
|
||||
id := h.ID()
|
||||
if newtab {
|
||||
h.AddTab()
|
||||
i = 0
|
||||
id = MainTab().Panes[0].ID()
|
||||
}
|
||||
|
||||
v := h.GetView()
|
||||
MainTab().Panes[i] = NewTermHandler(v.X, v.Y, v.Width, v.Height, t, id)
|
||||
MainTab().SetActive(i)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ var formatParser = regexp.MustCompile(`\$\(.+?\)`)
|
||||
// Display draws the statusline to the screen
|
||||
func (s *StatusLine) Display() {
|
||||
// TODO: don't display if infobar off and has message
|
||||
// if !GetGlobalOption("infobar").(bool) {
|
||||
// return
|
||||
// }
|
||||
if !config.GetGlobalOption("infobar").(bool) {
|
||||
return
|
||||
}
|
||||
|
||||
// We'll draw the line at the lowest line in the window
|
||||
y := s.win.Height + s.win.Y - 1
|
||||
@@ -84,7 +84,6 @@ func (s *StatusLine) Display() {
|
||||
return []byte(fmt.Sprint(s.FindOpt(string(option))))
|
||||
} else if bytes.HasPrefix(name, []byte("bind")) {
|
||||
binding := string(name[5:])
|
||||
// TODO: search bindings
|
||||
for k, v := range config.Bindings {
|
||||
if v == binding {
|
||||
return []byte(k)
|
||||
|
||||
@@ -94,8 +94,6 @@ func (t *Terminal) Start(execCmd []string, getOutput bool, wait bool) error {
|
||||
screen.Redraw()
|
||||
}
|
||||
t.Stop()
|
||||
// TODO: close Term
|
||||
// closeterm <- view.Num
|
||||
}()
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user