package widgets import ( gocolor "image/color" "os" "os/exec" "git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/go-libvterm" "git.sr.ht/~sircmpwn/pty" "github.com/gdamore/tcell" ) type vtermKey struct { Key vterm.Key Rune rune Mod vterm.Modifier } var keyMap map[tcell.Key]vtermKey func directKey(key vterm.Key) vtermKey { return vtermKey{key, 0, vterm.ModNone} } func runeMod(r rune, mod vterm.Modifier) vtermKey { return vtermKey{vterm.KeyNone, r, mod} } func keyMod(key vterm.Key, mod vterm.Modifier) vtermKey { return vtermKey{key, 0, mod} } func init() { keyMap = make(map[tcell.Key]vtermKey) keyMap[tcell.KeyCtrlSpace] = runeMod(' ', vterm.ModCtrl) keyMap[tcell.KeyCtrlA] = runeMod('a', vterm.ModCtrl) keyMap[tcell.KeyCtrlB] = runeMod('b', vterm.ModCtrl) keyMap[tcell.KeyCtrlC] = runeMod('c', vterm.ModCtrl) keyMap[tcell.KeyCtrlD] = runeMod('d', vterm.ModCtrl) keyMap[tcell.KeyCtrlE] = runeMod('e', vterm.ModCtrl) keyMap[tcell.KeyCtrlF] = runeMod('f', vterm.ModCtrl) keyMap[tcell.KeyCtrlG] = runeMod('g', vterm.ModCtrl) keyMap[tcell.KeyCtrlH] = runeMod('h', vterm.ModCtrl) keyMap[tcell.KeyCtrlI] = runeMod('i', vterm.ModCtrl) keyMap[tcell.KeyCtrlJ] = runeMod('j', vterm.ModCtrl) keyMap[tcell.KeyCtrlK] = runeMod('k', vterm.ModCtrl) keyMap[tcell.KeyCtrlL] = runeMod('l', vterm.ModCtrl) keyMap[tcell.KeyCtrlM] = runeMod('m', vterm.ModCtrl) keyMap[tcell.KeyCtrlN] = runeMod('n', vterm.ModCtrl) keyMap[tcell.KeyCtrlO] = runeMod('o', vterm.ModCtrl) keyMap[tcell.KeyCtrlP] = runeMod('p', vterm.ModCtrl) keyMap[tcell.KeyCtrlQ] = runeMod('q', vterm.ModCtrl) keyMap[tcell.KeyCtrlR] = runeMod('r', vterm.ModCtrl) keyMap[tcell.KeyCtrlS] = runeMod('s', vterm.ModCtrl) keyMap[tcell.KeyCtrlT] = runeMod('t', vterm.ModCtrl) keyMap[tcell.KeyCtrlU] = runeMod('u', vterm.ModCtrl) keyMap[tcell.KeyCtrlV] = runeMod('v', vterm.ModCtrl) keyMap[tcell.KeyCtrlW] = runeMod('w', vterm.ModCtrl) keyMap[tcell.KeyCtrlX] = runeMod('x', vterm.ModCtrl) keyMap[tcell.KeyCtrlY] = runeMod('y', vterm.ModCtrl) keyMap[tcell.KeyCtrlZ] = runeMod('z', vterm.ModCtrl) keyMap[tcell.KeyCtrlBackslash] = runeMod('\\', vterm.ModCtrl) keyMap[tcell.KeyCtrlCarat] = runeMod('^', vterm.ModCtrl) keyMap[tcell.KeyCtrlUnderscore] = runeMod('_', vterm.ModCtrl) keyMap[tcell.KeyEnter] = directKey(vterm.KeyEnter) keyMap[tcell.KeyTab] = directKey(vterm.KeyTab) keyMap[tcell.KeyBackspace] = directKey(vterm.KeyBackspace) keyMap[tcell.KeyEscape] = directKey(vterm.KeyEscape) keyMap[tcell.KeyUp] = directKey(vterm.KeyUp) keyMap[tcell.KeyDown] = directKey(vterm.KeyDown) keyMap[tcell.KeyLeft] = directKey(vterm.KeyLeft) keyMap[tcell.KeyRight] = directKey(vterm.KeyRight) keyMap[tcell.KeyInsert] = directKey(vterm.KeyIns) keyMap[tcell.KeyDelete] = directKey(vterm.KeyDel) keyMap[tcell.KeyHome] = directKey(vterm.KeyHome) keyMap[tcell.KeyEnd] = directKey(vterm.KeyEnd) keyMap[tcell.KeyPgUp] = directKey(vterm.KeyPageUp) keyMap[tcell.KeyPgDn] = directKey(vterm.KeyPageDown) for i := 0; i < 64; i++ { keyMap[tcell.Key(int(tcell.KeyF1)+i)] = directKey(vterm.Key(int(vterm.KeyFunction0) + i)) } keyMap[tcell.KeyTAB] = directKey(vterm.KeyTab) keyMap[tcell.KeyESC] = directKey(vterm.KeyEscape) keyMap[tcell.KeyDEL] = directKey(vterm.KeyBackspace) } type Terminal struct { ui.Invalidatable closed bool cmd *exec.Cmd colors map[tcell.Color]tcell.Color ctx *ui.Context cursorPos vterm.Pos cursorShown bool damage []vterm.Rect destroyed bool err error focus bool pty *os.File start chan interface{} vterm *vterm.VTerm OnClose func(err error) OnEvent func(event tcell.Event) bool OnStart fu
#!/usr/bin/python3
"""Generate pydoc documentation and move it to the doc directory.
THIS WILL DELETE ALL EXISTING HTML FILES IN THAT DIRECTORY, so don't
store important content there."""
import pydoc, os, sys
if __name__ == '__main__':
docdir = 'doc'
os.chdir(sys.path[0])
try: os.mkdir(docdir)
except: pass
for fname in os.listdir(docdir):
if fname.endswith('.html'):
os.remove(os.path.join