From 6a5ca2cd0ca800f69169be45ff2e12b3657a31a8 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 30 May 2019 00:02:25 -0700 Subject: [PATCH] Updated some doc and removed the "-B" flag for full key binding info --- bb.1 | 29 ++++++++++++++++++----------- bb.c | 25 +++++++++---------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/bb.1 b/bb.1 index 1ce64f2..d1719b7 100644 --- a/bb.1 +++ b/bb.1 @@ -8,7 +8,8 @@ bb \- A bitty browser for command line file management [\fI-d\fR] [\fI-s\fR] [\fI-0\fR] -[\fI-c commands... \fR] +[\fI-b\rR] +[\fI+command... \fR] [\fIdirectory\fR] .SH DESCRIPTION \fBbb\fR is a tiny TUI console application for browsing and managing files. @@ -19,12 +20,18 @@ Print the current directory on exit. .B \-s Print the selected files on exit. -.B \-s +.B \-0 If printing the selected files on exit, use NULL-terminated strings instead of newline-separated. -.B \-c commands... -From within \fBbb\fR, running \fBbb -c ...\fR will execute an internal bb +.B \-d +Print the current directory on exit. + +.B \-b +Print the bb key bindings and exit. + +.B \+command +From within \fBbb\fR, running \fBbb +command\fR will execute an internal bb command for modifying bb's state. .B directory @@ -47,8 +54,8 @@ cleared by pressing \fBEscape\fR. .TP .B Mouse: -Clicking on a file will select it. Double clicking will open it. Clicking on -the far left character of a file's row will toggle selection of that file. +Clicking on a file will move the cursor to it. Double clicking will open it. +Clicking on the '*' column of a file will toggle that file's selection. .SH EXAMPLES .TP @@ -56,16 +63,16 @@ the far left character of a file's row will toggle selection of that file. bb /usr/local/ Begin browsing in /usr/local/ -.TP -.B -bb -s -0 | xargs -0 zip archive.zip -Select some files to add to a zip archive. - .TP .B alias bb="cd '`/usr/local/bin/bb -d || pwd`'" Create an alias to launch \fBbb\fR and change directory to wherever it's located when you exit (unless you exit with Ctrl-c). +.TP +.B +bb -s -0 | xargs -0 zip archive.zip +Select some files to add to a zip archive. + .SH AUTHOR Bruce Hill (bruce@bruce-hill.com) diff --git a/bb.c b/bb.c index 7593296..5d863f3 100644 --- a/bb.c +++ b/bb.c @@ -129,7 +129,7 @@ static entry_t* load_entry(const char *path); static void populate_files(bb_t *bb, const char *path); static bb_result_t execute_cmd(bb_t *bb, const char *cmd); static void bb_browse(bb_t *bb, const char *path); -static void print_bindings(int verbose); +static void print_bindings(void); // Config options extern binding_t bindings[]; @@ -1303,16 +1303,16 @@ void bb_browse(bb_t *bb, const char *path) /* * Print the current key bindings */ -void print_bindings(int verbose) +void print_bindings(void) { struct winsize sz = {0}; ioctl(STDOUT_FILENO, TIOCGWINSZ, &sz); - int _width = sz.ws_col; - if (_width == 0) _width = 80; + int width = sz.ws_col; + if (width == 0) width = 80; char buf[1024]; char *kb = "Key Bindings"; - printf("\n\033[33;1;4m\033[%dG%s\033[0m\n\n", (_width-(int)strlen(kb))/2, kb); + printf("\n\033[33;1;4m\033[%dG%s\033[0m\n\n", (width-(int)strlen(kb))/2, kb); for (int i = 0; bindings[i].keys[0]; i++) { char *p = buf; for (int j = 0; bindings[i].keys[j]; j++) { @@ -1327,13 +1327,8 @@ void print_bindings(int verbose) p += sprintf(p, "\033[31m\\x%02X", key); } *p = '\0'; - printf("\033[1m\033[%dG%s\033[0m", _width/2 - 1 - (int)strlen(buf), buf); - printf("\033[0m\033[%dG\033[34;1m%s\033[0m", _width/2 + 1, bindings[i].description); - if (verbose) { - printf("\n\033[%dG\033[0;32m", MAX(1, (_width - (int)strlen(bindings[i].command))/2)); - fputs_escaped(stdout, bindings[i].command, "\033[0;32m"); - fflush(stdout); - } + printf("\033[1m\033[%dG%s\033[0m", width/2 - 1 - (int)strlen(buf), buf); + printf("\033[0m\033[%dG\033[34;1m%s\033[0m", width/2 + 1, bindings[i].description); printf("\033[0m\n"); } printf("\n"); @@ -1405,7 +1400,7 @@ int main(int argc, char *argv[]) if (strcmp(argv[i], "--help") == 0) { usage: printf("bb - an itty bitty console TUI file browser\n"); - printf("Usage: bb [-h/--help] [-s] [-b] [-0] [path]\n"); + printf("Usage: bb [-h/--help] [-s] [-b] [-d] [-0] (+command)* [path]\n"); return 0; } if (strcmp(argv[i], "--version") == 0) { @@ -1428,9 +1423,7 @@ int main(int argc, char *argv[]) break; case 's': print_selection = 1; break; - case 'b': print_bindings(0); - return 0; - case 'B': print_bindings(1); + case 'b': print_bindings(); return 0; } }