Start work on pager kitten

This commit is contained in:
Kovid Goyal
2024-01-19 15:09:20 +05:30
parent 7038292d11
commit 0bd50abd77
3 changed files with 67 additions and 2 deletions

32
kittens/pager/main.go Normal file
View File

@@ -0,0 +1,32 @@
// License: GPLv3 Copyright: 2024, Kovid Goyal, <kovid at kovidgoyal.net>
package pager
// TODO:
// Scroll to line when starting
// Visual mode elect with copy/paste and copy-on-select
// Mouse based wheel scroll, drag to select, drag scroll, double click to select
// Hyperlinks: Clicking should delegate to terminal and also allow user to specify action
// Keyboard hints mode for clicking hyperlinks
// Display images when used as scrollback pager
// automatic follow when input is a pipe/tty and on last line like tail -f
// syntax highlighting using chroma
import (
"fmt"
"kitty/tools/cli"
"kitty/tools/tty"
)
var _ = fmt.Print
var debugprintln = tty.DebugPrintln
var _ = debugprintln
func main(_ *cli.Command, opts_ *Options, args []string) (rc int, err error) {
return
}
func EntryPoint(parent *cli.Command) {
create_cmd(parent, main)
}

33
kittens/pager/main.py Normal file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python
# License: GPLv3 Copyright: 2024, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from typing import List
from kitty.cli import CompletionSpec
OPTIONS = '''
--role
default=pager
choices=pager,scrollback
The role the pager is used for. The default is a standard less like pager.
'''.format
help_text = 'Display text in a pager with various features such as searching, copy/paste, etc. Text can some from the specified file or from STDIN.'
usage = '[filename]'
def main(args: List[str]) -> None:
raise SystemExit('Must be run as kitten pager')
if __name__ == '__main__':
main(sys.argv)
elif __name__ == '__doc__':
cd = sys.cli_docs # type: ignore
cd['usage'] = usage
cd['options'] = OPTIONS
cd['help_text'] = help_text
cd['short_desc'] = 'Pretty, side-by-side diffing of files and images'
cd['args_completion'] = CompletionSpec.from_string('type:file mime:text/* group:"Text files"')