MCPcopy
hub / github.com/micro-editor/micro / TermCmd

Method TermCmd

internal/action/command.go:1170–1199  ·  view source on GitHub ↗

TermCmd opens a terminal in the current view

(args []string)

Source from the content-addressed store, hash-verified

1168
1169// TermCmd opens a terminal in the current view
1170func (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
1202func (h *BufPane) HandleCommand(input string) {

Callers

nothing calls this directly

Calls 6

openTermMethod · 0.95
closePromptMethod · 0.95
MainTabFunction · 0.85
ModifiedMethod · 0.80
SharedMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected