Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.1 KB
Raw Blame
import type { TerminalDocumentScope } from './document-scope'
import { notify } from './host-notify'
import { cancelSelect } from './selection-mode'
import { repositionOverlay } from './selection-overlay'

export function startSelectionMenuButtons(scope: TerminalDocumentScope) {
  scope.btnCopy!.addEventListener('click', function (e) {
    e.preventDefault()
    e.stopPropagation()
    if (!scope.term) {
      return
    }
    const text = scope.term.getSelection ? scope.term.getSelection() : ''
    if (text && text.length > 0) {
      notify(scope, { type: 'selection', text: text })
    } else {
      cancelSelect(scope)
    }
  })
  scope.btnSelAll!.addEventListener('click', function (e) {
    e.preventDefault()
    e.stopPropagation()
    if (!scope.term) {
      return
    }
    try {
      scope.term.selectAll()
      const b = scope.term.buffer.active
      scope.sel = {
        anchor: { col: 0, row: 0 },
        focus: { col: scope.term.cols - 1, row: b.length - 1 },
        activeHandle: null
      }
      repositionOverlay(scope)
    } catch {}
  })
}