From dc96cc6d1e9295b05dbeaa88df70056400a94bea Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Tue, 3 Nov 2020 23:29:47 +0100 Subject: [PATCH] Add zsh completion scripts Can't get bash ones to work, but these do. --- README.rst | 4 ++++ contrib/zsh_compl/_rgbasm | 49 ++++++++++++++++++++++++++++++++++++++ contrib/zsh_compl/_rgbfix | 25 +++++++++++++++++++ contrib/zsh_compl/_rgbgfx | 37 ++++++++++++++++++++++++++++ contrib/zsh_compl/_rgblink | 22 +++++++++++++++++ 5 files changed, 137 insertions(+) create mode 100644 contrib/zsh_compl/_rgbasm create mode 100644 contrib/zsh_compl/_rgbfix create mode 100644 contrib/zsh_compl/_rgbgfx create mode 100644 contrib/zsh_compl/_rgblink diff --git a/README.rst b/README.rst index 6cd1e414..2b2b1646 100644 --- a/README.rst +++ b/README.rst @@ -50,6 +50,8 @@ The RGBDS source code file structure somewhat resembles the following: │   └── workflows/ │      └── ... ├── contrib/ + │   ├── zsh_compl/ + │   │   └── ... │   └── ... ├── include/ │   └── ... @@ -79,6 +81,8 @@ The RGBDS source code file structure somewhat resembles the following: - ``contrib/`` - scripts and other resources which may be useful to users and developers of RGBDS. + * ``zsh_compl`` contains tab completion scripts for use with zsh. Put them somewhere in your ``fpath``, and they should auto-load. + - ``include/`` - header files for each respective C files in `src`. - ``src/`` - source code and manual pages for RGBDS. diff --git a/contrib/zsh_compl/_rgbasm b/contrib/zsh_compl/_rgbasm new file mode 100644 index 00000000..7800cf36 --- /dev/null +++ b/contrib/zsh_compl/_rgbasm @@ -0,0 +1,49 @@ +#compdef rgbasm + +_rgbasm_warnings() { + local warnings=( + 'error:Turn all warnings into errors' + + 'all:Enable most warning messages' + 'extra:Enable extra, possibly unwanted, messages' + 'everything:Enable literally everything' + + 'assert:Warn when WARN-type asserts fail' + 'builtin-args:Report incorrect args to built-in funcs' + 'div:Warn when dividing the smallest int by -1' + 'empty-entry:Warn on empty entries in db, dw, dl args' + 'large-constant:Warn on constants too large for a signed 32-bit int' + 'long-string:Warn on strings too long' + 'obsolete:Warn when using deprecated features' + 'shift:Warn when shifting negative values' + 'shift-amount:Warn when a shift'\''s operand it negative or \> 32' + 'truncation:Warn when implicit truncations lose bits' + 'user:Warn when executing the WARN built-in' + ) + # TODO: handle `no-` and `error=` somehow? + _describe warning warnings +} + +local args=( + # Arguments are listed here in the same order as in the manual, except for the version + '(- : * options)'{-V,--version}'[Print version number]' + + '(-E --export-all)'{-E,--export-all}'[Export all symbols]' + '(-h --halt-without-nop)'{-h,--halt-without-nop}'[Avoid outputting a `nop` after `halt`]' + '(-L ---preserve-ld)'{-L,--preserve-ld}'[Prevent auto-optimizing `ld` into `ldh`]' + '(-v --verbose)'{-v,--verbose}'[Print additional messages regarding progression]' + -w'[Disable all warnings]' + + '(-b --binary-digits)'{-b,--binary-digits}'+[Change chars for binary constants]:digit spec:' + '(-D --define)'{-D,--define}'+[Define a string symbol]:name + value (default 1):' + '(-g --gfx-chars)'{-g,--gfx-chars}'+[Change chars for gfx constants]:chars spec:' + '(-i --include)'{-i,--include}'+[Add an include directory]:include path:_files -/' + '(-M --dependfile)'{-M,--dependfile}"+[List deps in make format]:output file:_files -g '*.{d,mk}" + '(-o --output)'{-o,--output}'+[Output file]:output file:_files' + '(-p --pad-value)'{-p,--pad-value}'+[Set padding byte]:padding byte:' + '(-r --recursion-depth)'{-r,--recursion-depth}'+[Set maximum recursion depth]:depth:' + '(-W --warning)'{-W,--warning}'+[Toggle warning flags]:warning flag:_rgbasm_warnings' + + '*'":assembly sources:_files -g '*.asm'" +) +_arguments -s -S : $args diff --git a/contrib/zsh_compl/_rgbfix b/contrib/zsh_compl/_rgbfix new file mode 100644 index 00000000..17df79af --- /dev/null +++ b/contrib/zsh_compl/_rgbfix @@ -0,0 +1,25 @@ +#compdef rgbfix + +local args=( + # Arguments are listed here in the same order as in the manual, except for the version + '(- : * options)'{-V,--version}'[Print version number]' + + '(-C --color-only)'{-C,--color-only}'[Mark ROM as GBC-only]' + '(-c --color-compatible)'{-c,--color-compatible}'[Mark ROM as GBC-compatible]' + '(-j --non-japanese)'{-j,--non-japanese}'[Set the non-Japanese region flag]' + '(-s --sgb-compatible)'{-s,--sgb-compatible}'[Set the SGB flag]' + '(-f --fix-spec -v --validate)'{-v,--validate}'[Shorthand for -f lhg]' + + '(-f --fix-spec -v --validate)'{-f,--fix-spec}'+[Fix or trash some header values]:fix spec:' + '(-i --game-id)'{-i,--game-id}'+[Set game ID string]:4-char game ID:' + '(-k --new-licensee)'{-k,--new-licensee}'+[Set new licensee string]:2-char licensee ID:' + '(-l --old-licensee)'{-l,--old-licensee}'+[Set old licensee ID]:licensee number:' + '(-m --mbc-type)'{-m,--mbc-type}'+[Set MBC flags]:mbc flags byte:' + '(-n --rom-version)'{-n,--rom-version}'+[Set ROM version]:rom version byte:' + '(-p --pad-value)'{-p,--pad-value}'+[Pad to next valid size using this byte as padding]:padding byte:' + '(-r --ram-size)'{-r,--ram-size}'+[Set RAM size]:ram size byte:' + '(-t --title)'{-t,--title}'+[Set title string]:11-char title string:' + + '*'":ROM files:_files -g '*.{gb,sgb,gbc}'" +) +_arguments -s -S : $args diff --git a/contrib/zsh_compl/_rgbgfx b/contrib/zsh_compl/_rgbgfx new file mode 100644 index 00000000..c3c9a7e7 --- /dev/null +++ b/contrib/zsh_compl/_rgbgfx @@ -0,0 +1,37 @@ +#compdef rgbgfx + +_depths() { + local depths=( + '1:1bpp' + '2:2bpp (native)' + ) + + _describe 'bit depth' depths +} + +local args=( + # Arguments are listed here in the same order as in the manual, except for the version + '(- : * options)'{-V,--version}'[Print version number]' + + '(-a --attr-map -A --output-attr-map)'{-A,--output-attr-map}'[Shortcut for -a .attrmap]' + '(-C --color-curve)'{-C,--color-curve}'[Generate palettes using GBC color curve]' + '(-D --debug)'{-D,--debug}'[Enable debug features]' + '(-f --fix -F --fix-and-save)'{-f,--fix}'[Fix input PNG into an indexed image]' + '(-f --fix -F --fix-and-save)'{-F,--fix-and-save}'[Like -f but also save CLI params within the PNG]' + '(-h --horizontal)'{-h,--horizontal}'[Lay out tiles horizontally instead of vertically]' + '(-m --mirror-tiles)'{-m,--mirror-tiles}'[Eliminate mirrored tiles from output]' + '(-p --palette -P --output-palette)'{-P,--output-palette}'[Shortcut for -p .pal]' + '(-t --tilemap -T --output-tilemap)'{-T,--output-tilemap}'[Shortcut for -t .tilemap]' + '(-u --unique-tiles)'{-u,--unique-tiles}'[Eliminate redundant tiles]' + '(-v --verbose)'{-v,--verbose}'[Enable verbose output]' + + '(-a --attr-map -A --output-attr-map)'{-a,--attr-map}'+[Generate a map of tile attributes (mirroring)]:attrmap file:_files' + '(-d --depth)'{-d,--depth}'+[Set bit depth]:bit depth:_depths' + '(-o --output)'{-o,--output}'+[Set output file]:output file:_files' + '(-p --palette -P --output-palette)'{-p,--palette}"+[Output the image's palette in little-endian native RGB555 format]:palette file:_files" + '(-t --tilemap -T --output-tilemap)'{-t,--tilemap}'+[Generate a map of tile indices]:tilemap file:_files' + '(-x --trim-end)'{-x,--trim-end}'+[Trim end of output by this many tiles]:tile count:' + + '*'":input png files:_files -g '*.png'" +) +_arguments -s -S : $args diff --git a/contrib/zsh_compl/_rgblink b/contrib/zsh_compl/_rgblink new file mode 100644 index 00000000..e3e37995 --- /dev/null +++ b/contrib/zsh_compl/_rgblink @@ -0,0 +1,22 @@ +#compdef rgblink + +local args=( + # Arguments are listed here in the same order as in the manual, except for the version + '(- : * options)'{-V,--version}'[Print version number]' + + '(-d --dmg)'{-d,--dmg}'[Enable DMG mode (-w + no VRAM banking)]' + '(-t --tiny)'{-t,--tiny}'[Enable tiny mode, disabling ROM banking]' + '(-v --verbose)'{-v,--verbose}'[Enable verbose output]' + '(-w --wramx)'{-w,--wramx}'[Disable WRAM banking]' + + '(-l --linkerscript)'{-l,--linkerscript}"+[Use a linker script]:linker script:_files -g '*.link'" + '(-m --map)'{-m,--map}"+[Produce a map file]:map file:_files -g '*.map'" + '(-n --sym)'(-n,--sym)"+[Produce a symbol file]:sym file:_files -g '*.sym'" + '(-O --overlay)'{-O,--overlay}'+[Overlay sections over on top of bin file]:base overlay:_files' + '(-o --output)'{-o,--output}"+[Write ROM image to this file]:rom file:_files -g '*.{gb,sgb,gbc}'" + '(-p --pad-value)'{-p,--pad-value}'+[Set padding byte]:padding byte:' + '(-s --smart)'{-s,--smart}'+[!BROKEN! Perform smart linking from this symbol]:symbol name:' + + '*'":object files:_files -g '*.o'" +) +_arguments -s -S : $args