From 88f93d17e2abb69120762ffcb5c7685ff72483d1 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Tue, 27 Jun 2017 02:43:02 -0700 Subject: [PATCH] Adding some stuff to ease the process of reworking -h output. --- src/curses/ux_params.txt | 26 +++++++++++++++++ src/dumb/dumb_params.txt | 18 ++++++++++++ src/misc/twocol.pl | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 src/curses/ux_params.txt create mode 100644 src/dumb/dumb_params.txt create mode 100755 src/misc/twocol.pl diff --git a/src/curses/ux_params.txt b/src/curses/ux_params.txt new file mode 100644 index 0000000..b011fe1 --- /dev/null +++ b/src/curses/ux_params.txt @@ -0,0 +1,26 @@ +-a watch attribute setting +-A watch attribute testing +-b background color +-c # context lines +-d disable color +-e enable sound +-f foreground color +-F Force color mode +-h # screen height +-i ignore fatal errors +-l # left margin +-o watch object movement +-O watch object locating +-p plain ASCII output only +-P alter piracy opcode +-q quiet (disable sound effects) +-r # right margin +-R load this save file +-s # random number seed value +-S # transcript width +-t set Tandy bit +-u # slots for multiple undo +-v show version information +-w # screen width +-W write only to this path +-x expand abbreviations g/x/z diff --git a/src/dumb/dumb_params.txt b/src/dumb/dumb_params.txt new file mode 100644 index 0000000..c7ff370 --- /dev/null +++ b/src/dumb/dumb_params.txt @@ -0,0 +1,18 @@ +-a watch attribute setting +-A watch attribute testing +-h # screen height +-i ignore fatal errors +-I # interpreter number +-o watch object movement +-O watch object locating +-p plain ASCII output only +-P alter piracy opcode +-R load this save file +-s # random number seed value +-S # transcript width +-t set Tandy bit +-u # slots for multiple undo +-v show version information +-w # screen width +-W write only to this path +-x expand abbreviations g/x/z diff --git a/src/misc/twocol.pl b/src/misc/twocol.pl new file mode 100755 index 0000000..5b547d8 --- /dev/null +++ b/src/misc/twocol.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl -w + +# This script is intended to speed up the process of adding new command +# line parameters to the "help" output of text-mode programs. Most +# people want to have the progression of parameters go down the left +# column and then down the right. Prior to using this script, put your +# parameter descriptions in a text file, one parameter per line. Figure +# out where you want the column to end and put that number in $middle. +# This will cause the output to skip over that many spaces and then the +# second column will begin. +# +# When you're all set up, run this script and give the filename of your +# parameter text file. Your parameters, formatted into two columns with +# a '\t' for the tab in the middle, will be printed to STDOUT. Now you +# can put that text into a #define or a really long printf(). +# +# In short, if your parameters file looks like this: +# A +# B +# C +# D +# You'll get this: +# A \t C\n\ +# B \t D\n\ +# +# I've seen scripts that do this before and forgot where they were, so I +# made this one from scratch. Wherever you find it, please feel free to +# incorporate it into whatever project you feel appropriate. I release +# all rights to it to the public domain. +# +# Written in June 2017 by David Griffith +# + +use POSIX; + +my @lines; +my $leftside; +my $middle = 34; # put a tab in the 35th column +my $skip; + +open(INFILE, "<$ARGV[0]"); +chomp(@lines = ); +close(INFILE); + +@lines = grep(/\S/, @lines); + +if (scalar @lines % 2 == 1) { push @lines, ""; } + +$leftsize = ceil(scalar @lines / 2); +for (my $i = 0; $i < $leftsize; $i++) { + $skip = $middle - (2 + length($lines[$i])); + print " $lines[$i]"; + if ($lines[$i + $leftsize] eq "") { + print "\\n\n"; + } else { + print " " x $skip . "\\t $lines[$i + $leftsize]\\n\\\n"; + } +} + + -- 2.34.1