Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions slmenu.1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ slmenu \- single line menu
.RB [ \-p
.IR prompt ]
.RB [ \-v ]
.RB [ \-h ]
.SH DESCRIPTION
.B slmenu
is a dynamic menu for the console, based on the wonderful
Expand Down Expand Up @@ -40,6 +41,9 @@ defines the prompt to be displayed to the left of the input field.
.TP
.B \-v
prints version information to stdout, then exits.
.TP
.B \-h
prints usage information to stdout, then exits.
.SH USAGE
slmenu is completely controlled by the keyboard. Besides standard Unix line
editing and item selection (arrow keys, page up/down, home and end), the
Expand Down
18 changes: 18 additions & 0 deletions slmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void resetline(void);
static void setup(void);
static size_t textw(const char*);
static size_t textwn(const char*, int);
static void usage(void);

static char text[BUFSIZ] = "";
static int barpos = 0;
Expand Down Expand Up @@ -632,6 +633,18 @@ size_t textwn(const char *s, int l) {
return c+2;
}

void usage(void) {
puts("usage: slmenu [-bhitv] [-l lines] [-p prompt]\n"
"\n"
" -b appear at the bottom of the terminal\n"
" -t appear at the top of the terminal\n"
" -i match menu items case insensitively\n"
" -l lines list items vertically, on the given number of lines\n"
" -p prompt display prompt to the left of the input field\n"
" -v print version information and exit\n"
" -h print this help and exit");
}

int main(int argc, char **argv) {
int i;

Expand All @@ -642,6 +655,11 @@ int main(int argc, char **argv) {
puts("slmenu, © 2011 slmenu engineers, see LICENSE for details");
exit(EXIT_SUCCESS);

} else if (!strcmp(argv[i], "-h")) {
/* help */
usage();
exit(EXIT_SUCCESS);

} else if (!strcmp(argv[i], "-i")) {
/* case insensitive */
fstrncmp = strncasecmp;
Expand Down