aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-11 15:22:26 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-11 15:22:26 +0100
commiteb53e8f87133640e891719ac9974b82869105f06 (patch)
tree1086af2dfeccd47c313ea8994bc7e468750c9d76
parentpng conversion is no longer done in a separate process. (diff)
downloadscrotty-eb53e8f87133640e891719ac9974b82869105f06.tar.gz
scrotty-eb53e8f87133640e891719ac9974b82869105f06.tar.bz2
scrotty-eb53e8f87133640e891719ac9974b82869105f06.tar.xz
add shell tab-completion + fix translation
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r--DEPENDENCIES1
-rw-r--r--INSTALL9
-rw-r--r--Makefile.in13
-rw-r--r--NEWS5
-rw-r--r--TODO2
-rwxr-xr-xconfigure8
-rw-r--r--doc/man/scrotty.sv.12
-rw-r--r--mk/all.mk1
-rw-r--r--mk/configure9
-rw-r--r--mk/dist.mk4
-rw-r--r--mk/shell.mk223
-rw-r--r--mk/tools.mk3
-rw-r--r--po/sv.po2
-rw-r--r--src/scrotty.auto-completion23
-rw-r--r--src/scrotty.sv.auto-completion23
15 files changed, 321 insertions, 7 deletions
diff --git a/DEPENDENCIES b/DEPENDENCIES
index d85870b..4ecfdbe 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -16,6 +16,7 @@ BUILD DEPENDENCIES:
gettext (opt-out, for internationalisation)
texinfo (opt-out, for info, pdf, dvi, ps, and html manuals)
texlive-plainextra (opt-in, for pdf, dvi, and ps manuals)
+ auto-auto-complete (opt-in, for bash, fish, and zsh tab-completion)
INSTALL DEPENDENCIES:
diff --git a/INSTALL b/INSTALL
index c267f74..a088b9d 100644
--- a/INSTALL
+++ b/INSTALL
@@ -89,6 +89,10 @@ to install. This rules are available:
│ html │ install-html │ Include multifile HTML manual. (Texinfo) │
│ │ install-man │ Include man pages. │
│ locale │ install-locale │ Include locales. │
+│ shell │ install-shell │ Include shell tab-completion. │
+│ bash │ install-bash │ Include GNU Bash tab-completion. │
+│ fish │ install-fish │ Include fish tab-completion. │
+│ zsh │ install-zsh │ Include Z shell tab-completion. │
└─────────────┴─────────────────────┴────────────────────────────────────────────┘
install, install-everything, install-base, and install-cmd, have alternatives
@@ -99,3 +103,8 @@ The untranslated man page is installed via the rule install-man-untranslated.
Additional translations are installed via the rule install-man-locale, which
installes the locales listed in MAN_LOCALES.
+It is not possible to multiple translations of the tab-completion scripts.
+But you may select select one translation by setting SHELL_LOCALE. Note,
+doing this means that the non-translationed script will not be installed.
+A translated one will be installed in its place.
+
diff --git a/Makefile.in b/Makefile.in
index af7ea0c..acfa38d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -93,6 +93,19 @@ _EVERYTHING = $(foreach F,$(___EVERYTHING_INFO),doc/info/$(F).texinfo) \
$(foreach F,$(___EVERYTHING_H),src/$(F).h) \
$(__EVERYTHING_ALL_COMMON) DEPENDENCIES INSTALL NEWS $(__todo) doc/concept
+# Used by mk/shell.mk
+_AUTO_COMPLETE = scrotty
+_WITH_SHELL = 1
+ifndef WITH_BASH
+WITHOUT_BASH = 1
+endif
+ifndef WITH_FISH
+WITHOUT_FISH = 1
+endif
+ifndef WITH_ZSH
+WITHOUT_ZSH = 1
+endif
+
# }}
diff --git a/NEWS b/NEWS
index 1bd2dad..cdb09ad 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,8 @@ scrotty NEWS -*- outline -*-
The GNU C library, or any POSIX-compliant C standard
library with the getopt_long function, is now required.
+ auto-auto-complete as been added as a optional dependency.
+
** Improvements
The option --raw has been added. This option makes scrotty
@@ -39,6 +41,9 @@ scrotty NEWS -*- outline -*-
Performance is significantly improved (for PNG images)
because images are stored directly as PNG and not converted.
+ Tab-completion for GNU Bash, fish, and Z shell has been
+ added as an optional features.
+
** Translations
The program and the man page has been translated to Swedish.
diff --git a/TODO b/TODO
index 5f2f61a..3ea40ad 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
-Use auto-auto-complete.
-
(maybe) include date and time by default in filenames.
Take the screenshot of the framebuffers more simultaneously. (async)
diff --git a/configure b/configure
index 70669bd..acd133e 100755
--- a/configure
+++ b/configure
@@ -20,6 +20,9 @@ list_optional_features_help ()
{
cat <<EOF
--without-gettext Do not support internationalisation.
+ --with-bash Include tab-completion for GNU Bash, requires the auto-auto-complete package.
+ --with-fish Include tab-completion for fish, requires the auto-auto-complete package.
+ --with-zsh Include tab-completion for Z shell, requires the auto-auto-complete package.
EOF
}
@@ -47,7 +50,10 @@ cat <<EOF
Enabled features, see ${0} for more infomation:
- Internationalisation $(test_with GETTEXT yes)
+ Internationalisation $(test_with GETTEXT yes)
+ GNU Bash tab-completion $(test_with BASH no)
+ Fish tab-completion $(test_with FISH no)
+ Z shell tab-completion $(test_with ZSH no)
You can now run 'make && make install'.
diff --git a/doc/man/scrotty.sv.1 b/doc/man/scrotty.sv.1
index 2cc157e..0e294f6 100644
--- a/doc/man/scrotty.sv.1
+++ b/doc/man/scrotty.sv.1
@@ -32,7 +32,7 @@ Skriv ut burksanvisningar.
Skriv ut programmets namn och version.
.TP
.B \-c ,\ \-\-copyright
-Skriv ut upphovsrätts information.
+Skriv ut upphovsrättsinformation.
.TP
.B \-r ,\ \-\-raw
Spara som PNM-bild snarare än som PNG-bild.
diff --git a/mk/all.mk b/mk/all.mk
index f6cad42..9e21e7d 100644
--- a/mk/all.mk
+++ b/mk/all.mk
@@ -25,6 +25,7 @@ include $(v)mk/lang-c.mk
include $(v)mk/texinfo.mk
include $(v)mk/man.mk
include $(v)mk/i18n.mk
+include $(v)mk/shell.mk
include $(v)mk/clean.mk
include $(v)mk/dist.mk
include $(v)mk/tags.mk
diff --git a/mk/configure b/mk/configure
index 61f73e6..6351380 100644
--- a/mk/configure
+++ b/mk/configure
@@ -220,12 +220,14 @@ for option; do
feature="WITH_${feature}"
echo "${feature}" = yes >&20
export "${feature}"=yes
+ option="${option}=x"
;;
(--without-*)
feature="WITHOUT_${feature}"
echo "${feature}" = yes >&20
export "${feature}"=yes
+ option="${option}=x"
;;
(--enable-*=*)
@@ -245,12 +247,14 @@ for option; do
feature="DISABLE_${feature}"
echo "${feature}" = yes >&20
export "${feature}"=yes
+ option="${option}=x"
;;
(--disable-*)
feature="DISABLE_${feature}"
echo "${feature}" = yes >&20
export "${feature}"=yes
+ option="${option}=x"
;;
# unrecognised
@@ -711,7 +715,10 @@ test_enable ()
#
# Enabled features, see ${0} for more infomation:
#
-# Internationalisation $(test_with GETTEXT yes)
+# Internationalisation $(test_with GETTEXT yes)
+# GNU Bash tab-completion $(test_with BASH yes)
+# Fish tab-completion $(test_with FISH yes)
+# Z shell tab-completion $(test_with ZSH yes)
#
# You can now run 'make && make install'.
#
diff --git a/mk/dist.mk b/mk/dist.mk
index a2a3edf..b6db9e6 100644
--- a/mk/dist.mk
+++ b/mk/dist.mk
@@ -38,12 +38,14 @@ GPG_KEY ?=
__EVERYTHING_COMMON = $(_COPYING) $(_LICENSE) README
__EVERYTHING_SRC = $(foreach F,$(_SRC),src/$(F))
__EVERYTHING_LOCALE = $(foreach L,$(LOCALES),po/$(L).po)
+__EVERYTHING_SHELL = $(foreach F,$(_AUTO_COMPLETE),src/$(F).auto-completion) \
+ $(foreach F,$(_AUTO_COMPLETE),$(foreac F,$(_SHELL_LOCALES),src/$(F).$(L),auto-completion))
__EVERYTHING_MK_ = all clean copy dist empty i18n lang-c lowerpath man path prologue tags texinfo tools
__EVERYTHING_MK = $(foreach F,$(__EVERYTHING_MK_),mk/$(F).mk) mk/configure mk/README configure Makefile.in
__EVERYTHING_MAN = $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),doc/man/$(P).$(S))) \
$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach L,$(MAN_LOCALES),$(foreach P,$(_MAN_$(L)_$(S)),doc/man/$(P).$(L).$(S))))
__EVERYTHING_ALL_COMMON = $(__EVERYTHING_COMMON) $(__EVERYTHING_MK) $(__EVERYTHING_MAN) \
- $(__EVERYTHING_LOCALE) $(__EVERYTHING_SRC)
+ $(__EVERYTHING_LOCALE) $(__EVERYTHING_SRC) $(__EVERYTHING_SHELL)
# This one (__todo) if you have a todo file, but do not want it to be greped.
__TO__ = TO
__DO__ = DO
diff --git a/mk/shell.mk b/mk/shell.mk
new file mode 100644
index 0000000..49b50b7
--- /dev/null
+++ b/mk/shell.mk
@@ -0,0 +1,223 @@
+# Copyright (C) 2015 Mattias Andrée <maandree@member.fsf.org>
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved. This file is offered as-is,
+# without any warranty.
+
+
+#=== These rules are used for shell tab-completion using auto-auto-complete. ===#
+
+
+# Enables the rules:
+# shell Build tab-completion for all supported shells
+# bash Build GNU Bash tab-completion
+# fish Build fish tab-completion
+# zhs Build Z shell tab-completion
+# install-shell Install tab-completion for all supported shells
+# install-bash Install GNU Bash tab-completion
+# install-fish Install fish tab-completion
+# install-zsh Install Z shell tab-completion
+#
+# This file is ignored unless
+# _AUTO_COMPLETE is defined.
+#
+# _AUTO_COMPLETE shall list all commands that
+# have an auto-auto-complete. These should be
+# named src/$(COMMAND).auto-completion, where
+# $(COMMAND) is the command with the script.
+# If all auto-auto-complete scripts translations
+# named src/$(COMMAND).$(LOCALE).auto-completion,
+# SHELL_LOCALE can be set to install exactly
+# on translation in place of the non-translated
+# versions.
+#
+# Although not used by this file, you should
+# define _SHELL_LOCALES that lists all available
+# translations. (it is used by dist.mk.)
+#
+# You should also define _WITH_SHELL if you
+# want shell tab-completion unless the user
+# specifies otherwise. If you want it for
+# just some shells, define _WITH_$(SHELL)
+# for those shells instead of _WITH_SHELL.
+
+
+ifdef _AUTO_COMPLETE
+
+
+# HELP VARIABLES:
+
+# Include all that were not explicitly excluded?
+ifdef _WITH_SHELL
+_WITH_BASH = 1
+_WITH_FISH = 1
+_WITH_ZSH = 1
+endif
+
+# Include for GNU Bash?
+ifdef WITH_BASH
+__WITH_BASH = 1
+endif
+ifndef WITH_BASH
+ifndef WITHOUT_BASH
+ifdef _WITH_BASH
+__WITH_BASH = 1
+endif
+endif
+endif
+
+# Include for fish?
+ifdef WITH_FISH
+__WITH_FISH = 1
+endif
+ifndef WITH_FISH
+ifndef WITHOUT_FISH
+ifdef _WITH_FISH
+__WITH_FISH = 1
+endif
+endif
+endif
+
+# Include for Z Shell?
+ifdef WITH_ZSH
+__WITH_ZSH = 1
+endif
+ifndef WITH_ZSH
+ifndef WITHOUT_ZSH
+ifdef _WITH_ZSH
+__WITH_ZSH = 1
+endif
+endif
+endif
+
+# WHEN TO BUILD, INSTALL, AND UNINSTALL:
+
+all: shell
+everything: shell
+install: install-shell
+install-doc: install-info install-dvi install-pdf install-ps install-html
+uninstall: uninstall-shell
+
+shell:
+install-shell:
+
+ifdef __WITH_BASH
+shell: bash
+install-shell: install-bash
+endif
+ifdef __WITH_FISH
+shell: fish
+install-shell: install-fish
+endif
+ifdef __WITH_ZSH
+shell: zsh
+install-shell: install-zsh
+endif
+
+
+# HELP VARIABLES:
+
+# Affixes on the source files.
+ifdef SHELL_LOCALE
+__AAC_L = .$(SHELL_LOCALE)
+endif
+__AAC = $(__AAC_L).auto-completion
+
+# Customised command name.
+ifdef COMMAND
+ifeq ($(shell $(PRINTF) '%s\n' $(COMMAND) | $(WC) -l),1)
+ifeq ($(shell $(PRINTF) '%s\n' $(_AUTO_COMPLETE) | $(WC) -l),1)
+__SHELL_COMMAND = "command=$(COMMAND)"
+endif
+endif
+endif
+
+
+# BUILD RULES:
+
+.PHONY: bash
+bash: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).bash-completion)
+
+.PHONY: fish
+fish: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).fish-completion)
+
+.PHONY: zsh
+zsh: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).zsh-completion)
+
+bin/%.bash-completion: $(v)src/%$(__AAC)
+ @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
+ @$(MKDIR) -p bin
+ $(Q)$(AUTO_AUTO_COMPLETE) bash -o $@ -s $< $(__SHELL_COMMAND) #$Z
+ @$(ECHO_EMPTY)
+
+bin/%.fish-completion: $(v)src/%$(__AAC)
+ @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
+ @$(MKDIR) -p bin
+ $(Q)$(AUTO_AUTO_COMPLETE) fish -o $@ -s $< $(__SHELL_COMMAND) #$Z
+ @$(ECHO_EMPTY)
+
+bin/%.zsh-completion: $(v)src/%$(__AAC)
+ @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
+ @$(MKDIR) -p bin
+ $(Q)$(AUTO_AUTO_COMPLETE) zsh -o $@ -s $< $(__SHELL_COMMAND) #$Z
+ @$(ECHO_EMPTY)
+
+
+# INSTALL RULES:
+
+.PHONY: install-bash
+install-bash: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).bash-completion)
+ @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/bash-completion/completions"
+ifndef __SHELL_COMMAND
+ $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).bash-completion -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(F)" &&) $(TRUE)
+endif
+ifdef __SHELL_COMMAND
+ $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
+endif
+ @$(ECHO_EMPTY)
+
+.PHONY: install-fish
+install-fish: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).fish-completion)
+ @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/fish/completions"
+ifndef __SHELL_COMMAND
+ $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).fish-completion -- "$(DESTDIR)$(DATADIR)/fish/completions/$(F).fish" &&) $(TRUE)
+endif
+ifdef __SHELL_COMMAND
+ $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
+endif
+ @$(ECHO_EMPTY)
+
+.PHONY: install-zsh
+install-zsh: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).zsh-completion)
+ @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/zsh/site-functions"
+ifndef __SHELL_COMMAND
+ $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).zsh-completion -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(F)" &&) $(TRUE)
+endif
+ifdef __SHELL_COMMAND
+ $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
+endif
+ @$(ECHO_EMPTY)
+
+
+# UNINSTALL RULES:
+
+.PHONY: uninstall-shell
+uninstall-shell:
+ifndef __SHELL_COMMAND
+ -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/bash-completion/completions/$(F)")
+ -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/fish/completions/$(F).fish")
+ -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(F)")
+endif
+ifdef __SHELL_COMMAND
+ -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
+ -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
+ -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
+endif
+
+
+endif
+
diff --git a/mk/tools.mk b/mk/tools.mk
index 5801d4f..63d6d66 100644
--- a/mk/tools.mk
+++ b/mk/tools.mk
@@ -147,6 +147,9 @@ BZIP2_COMPRESS ?= $(BZIP2) -k9
XZ ?= xz
XZ_COMPRESS ?= $(XZ) -ke9
+# Part of auto-auto-complete:
+AUTO_AUTO_COMPLETE ?= auto-auto-complete
+
# Change to $(TRUE) to suppress the bold red and blue output.
ifndef PRINTF_INFO
diff --git a/po/sv.po b/po/sv.po
index e92e8ec..0020c9d 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -97,7 +97,7 @@ msgstr ""
"ALTERNATIV\n"
"\t-h, --help Skriv ut burksanvisningar.\n"
"\t-v, --version Skriv ut programmets namn och version.\n"
-"\t-c, --copyright Skriv ut upphovsrätts information.\n"
+"\t-c, --copyright Skriv ut upphovsrättsinformation.\n"
"\t-r, --raw Spara som PNM-bild snarare än som PNG-bild.\n"
"\t-e, --exec KMD Kommando att köra för varje sparad bild.\n"
"\n"
diff --git a/src/scrotty.auto-completion b/src/scrotty.auto-completion
new file mode 100644
index 0000000..8e9e91f
--- /dev/null
+++ b/src/scrotty.auto-completion
@@ -0,0 +1,23 @@
+((value command scrotty)
+ (default (arg FILENAME-PATTERN) (files -0) (suggest filename)
+ (desc 'Pattern for the filenames of saved images.'))
+
+ (unargumented (options -h --help) (complete --version)
+ (desc 'Print usage information.'))
+
+ (unargumented (options -v --version) (complete --version)
+ (desc 'Print program name and version.'))
+
+ (unargumented (options -c --copyright) (complete --copyright)
+ (desc 'Print copyright information.'))
+
+ (unargumented (options -r --raw) (complete --raw)
+ (desc 'Save in PNM rather than in PNG.'))
+
+ (argumented (options -e --exec) (complete --exec) (arg COMMAND) (files -0)
+ (desc 'Command to run for each saved image.'))
+
+ (suggestion filename (verbatim '%Y-%m-%d_%H:%M:%S_$wx$h.$i.png'
+ '%Y-%m-%d_%H:%M:%S.$i.png'))
+)
+
diff --git a/src/scrotty.sv.auto-completion b/src/scrotty.sv.auto-completion
new file mode 100644
index 0000000..24bd201
--- /dev/null
+++ b/src/scrotty.sv.auto-completion
@@ -0,0 +1,23 @@
+((value command scrotty)
+ (default (arg FILNAMNSMÖNSTER) (files -0) (suggest filename)
+ (desc 'Filnamnsmönster för sparade bilder.'))
+
+ (unargumented (options -h --help) (complete --version)
+ (desc 'Skriv ut burksanvisningar.'))
+
+ (unargumented (options -v --version) (complete --version)
+ (desc 'Skriv ut programmets namn och version.'))
+
+ (unargumented (options -c --copyright) (complete --copyright)
+ (desc 'Skriv ut upphovsrättsinformation.'))
+
+ (unargumented (options -r --raw) (complete --raw)
+ (desc 'Spara som PNM-bild snarare än som PNG-bild.'))
+
+ (argumented (options -e --exec) (complete --exec) (arg KOMMANDO) (files -0)
+ (desc 'Kör ett Kommando för varje sparad bild.'))
+
+ (suggestion filename (verbatim '%Y-%m-%d_%H:%M:%S_$wx$h.$i.png'
+ '%Y-%m-%d_%H:%M:%S.$i.png'))
+)
+