MCPcopy Create free account
hub / github.com/diillson/chatcli / handleCtrlC

Method handleCtrlC

cli/cli.go:1469–1506  ·  view source on GitHub ↗
(buf *prompt.Buffer)

Source from the content-addressed store, hash-verified

1467}
1468
1469func (cli *ChatCLI) handleCtrlC(buf *prompt.Buffer) {
1470 // Cancel multiline mode on Ctrl+C
1471 if cli.multilineBuf.Active() {
1472 cli.multilineBuf.Reset()
1473 buf.DeleteBeforeCursor(len([]rune(buf.Text())))
1474 fmt.Printf("\n [%s]\n", i18n.T("multiline.canceled"))
1475 return
1476 }
1477
1478 if cli.isExecuting.Load() {
1479 // Clear queued messages first
1480 cli.messageQueueMu.Lock()
1481 queueLen := len(cli.messageQueue)
1482 cli.messageQueue = cli.messageQueue[:0]
1483 cli.messageQueueMu.Unlock()
1484
1485 if queueLen > 0 {
1486 fmt.Printf("\n %s", colorize(i18n.T("queue.messages_removed", queueLen), ColorYellow))
1487 }
1488
1489 fmt.Println(i18n.T("prompt.cancel_op"))
1490
1491 cli.mu.Lock()
1492 if cli.operationCancel != nil {
1493 cli.operationCancel()
1494 }
1495 cli.mu.Unlock()
1496
1497 cli.interactionState = StateNormal
1498
1499 cli.forceRefreshPrompt()
1500
1501 } else {
1502 fmt.Println(i18n.T("prompt.confirm_exit"))
1503 cli.cleanup(context.Background())
1504 os.Exit(0)
1505 }
1506}
1507
1508// handleEscape detects Esc+Esc double-press for rewind.
1509// Only triggers when the input buffer is empty.

Callers

nothing calls this directly

Calls 9

forceRefreshPromptMethod · 0.95
cleanupMethod · 0.95
TFunction · 0.92
colorizeFunction · 0.85
ActiveMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
ResetMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected