TermCmd opens a terminal in the current view
(args []string)
| 1168 | |
| 1169 | // TermCmd opens a terminal in the current view |
| 1170 | func (h *BufPane) TermCmd(args []string) { |
| 1171 | if !TermEmuSupported { |
| 1172 | InfoBar.Error("Terminal emulator not supported on this system") |
| 1173 | return |
| 1174 | } |
| 1175 | |
| 1176 | if len(args) == 0 { |
| 1177 | sh := os.Getenv("SHELL") |
| 1178 | if sh == "" { |
| 1179 | InfoBar.Error("Shell environment not found") |
| 1180 | return |
| 1181 | } |
| 1182 | args = []string{sh} |
| 1183 | } |
| 1184 | |
| 1185 | // If there is only one open file we make a new tab instead of overwriting it |
| 1186 | newtab := len(MainTab().Panes) == 1 && len(Tabs.List) == 1 |
| 1187 | if newtab { |
| 1188 | h.openTerm(args, true) |
| 1189 | return |
| 1190 | } |
| 1191 | |
| 1192 | if h.Buf.Modified() && !h.Buf.Shared() { |
| 1193 | h.closePrompt("Save", func() { |
| 1194 | h.openTerm(args, false) |
| 1195 | }) |
| 1196 | } else { |
| 1197 | h.openTerm(args, false) |
| 1198 | } |
| 1199 | } |
| 1200 | |
| 1201 | // HandleCommand handles input from the user |
| 1202 | func (h *BufPane) HandleCommand(input string) { |