changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/lib/cli/tools/term.lisp

changeset 698: 96958d3eb5b0
parent: 6359b351657a
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 ;;; term.lisp --- Terminal Tools
2 
3 ;; Control and spawn terminal consoles from Lisp.
4 
5 ;;; Commentary:
6 
7 ;; This package is intended to make it easier to work with interactive
8 ;; terminal programs in a Lispy manner.
9 
10 ;;; Code:
11 (in-package :cli/tools/term)
12 
13 (deferror terminal-error (simple-error error) ())
14 
15 (defun terminal-error (fmt &rest args)
16  (error 'terminal-error :format-arguments args :format-control fmt))
17 
18 (defparameter *terminal* (or (find-exe "alacritty") (find-exe "xterm")))
19 
20 (defparameter *alacritty-config-path* (merge-pathnames ".config/alacritty.toml" (user-homedir-pathname)))
21 
22 (defun run-terminal (&rest args)
23  (apply #'sb-ext:run-program *terminal* args))
24 
25 (defmacro with-terminal ((sym &key args input output) &body body)
26  `(let ((,sym (run-terminal ,args
27  ,@(when input '(:input :stream))
28  ,@(when output '(:output :stream))
29  :wait nil)))
30  (let (,@(when input `((,input (sb-ext:process-input ,sym))))
31  ,@(when output `((,output (sb-ext:process-output ,sym)))))
32  ,@body)))