Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add K option to disable toggling of keyboard transmit mode #247

Merged
merged 1 commit into from
Sep 19, 2017
Merged
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
8 changes: 7 additions & 1 deletion pick.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.Nd fuzzy select anything
.Sh SYNOPSIS
.Nm
.Op Fl hvS
.Op Fl hvKS
.Op Fl d Op Fl o
.Op Fl x | Fl X
.Op Fl q Ar query
Expand All @@ -32,6 +32,12 @@ Both parts will be displayed but only the first part will be used when
searching.
.It Fl h
Output a help message and exit.
.It Fl K
Disable toggling of keyboard transmit mode.
Useful when running
.Nm
from within another interactive program which already has set the correct
transmit mode.
.It Fl o
Output description of selected choice on exit.
.It Fl q Ar query
Expand Down
16 changes: 11 additions & 5 deletions pick.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static unsigned int choices_lines, tty_columns, tty_lines;
static int descriptions;
static int sort = 1;
static int use_alternate_screen = 1;
static int use_keypad = 1;

int
main(int argc, char *argv[])
Expand All @@ -126,11 +127,14 @@ main(int argc, char *argv[])
err(1, "pledge");
#endif

while ((c = getopt(argc, argv, "dhoq:SvxX")) != -1)
while ((c = getopt(argc, argv, "dhoq:KSvxX")) != -1)
switch (c) {
case 'd':
descriptions = 1;
break;
case 'K':
use_keypad = 0;
break;
case 'o':
/*
* Only output description if descriptions are read and
Expand Down Expand Up @@ -198,9 +202,10 @@ main(int argc, char *argv[])
__dead void
usage(void)
{
fprintf(stderr, "usage: pick [-hvS] [-d [-o]] [-x | -X] [-q query]\n"
fprintf(stderr, "usage: pick [-hvKS] [-d [-o]] [-x | -X] [-q query]\n"
" -h output this help message and exit\n"
" -v output the version and exit\n"
" -K disable toggling of keyboard transmit mode\n"
" -S disable sorting\n"
" -d read and display descriptions\n"
" -o output description of selected on exit\n"
Expand Down Expand Up @@ -678,11 +683,11 @@ tty_init(int doinit)

tty_size();

if (use_keypad)
tty_putp(keypad_xmit, 0);
if (use_alternate_screen)
tty_putp(enter_ca_mode, 0);

tty_putp(keypad_xmit, 0);

toggle_sigwinch(0);
}

Expand Down Expand Up @@ -721,10 +726,11 @@ tty_restore(int doclose)
if (doclose)
fclose(tty_in);

tty_putp(keypad_local, 0);
tty_putp(carriage_return, 1); /* move cursor to first column */
tty_putp(clr_eos, 1);

if (use_keypad)
tty_putp(keypad_local, 0);
if (use_alternate_screen)
tty_putp(exit_ca_mode, 0);

Expand Down