sob

Simple output bar
git clone https://git.sinitax.com/codemadness/sob
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit b072bb3bd5fdff06b0a12cd7bc6a8f94962ab97d
parent 13970fc40d3282194523858158507d5592123512
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Thu,  2 Oct 2014 11:27:59 +0000

consistency: make resize a bindable function

make resize a script, remove resizecmd.

Diffstat:
Mconfig.def.h | 2+-
Ascripts/resize | 2++
Msob.1 | 5-----
Msob.c | 19+++++++++++--------
4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -2,7 +2,7 @@ static const char *prompt = "> "; static const char *completenickcmd[] = { "/bin/sh", "-c", "$HOME/.sob/scripts/complete_nick", NULL }; static const char *historycmd[] = { "/bin/sh", "-c", "$HOME/.sob/scripts/history", NULL }; static const char *yankcmd[] = { "/bin/sh", "-c", "/bin/xsel -i -p", NULL }; -static const char *resizecmd = "tmux resize-pane -y 4 2> /dev/null"; +static const char *resizecmd[] = { "/bin/sh", "-c", "$HOME/.sob/scripts/resize", NULL }; static void line_yank(void) diff --git a/scripts/resize b/scripts/resize @@ -0,0 +1,2 @@ +#!/bin/sh +tmux resize-pane -y 4 2> /dev/null diff --git a/sob.1 b/sob.1 @@ -9,8 +9,6 @@ sob \- simple output bar .IR line ] .RB [ \-p .IR prompt ] -.RB [ \-r -.IR resizecmd ] .SH DESCRIPTION sob is a simple line editor. .SH OPTIONS @@ -23,8 +21,5 @@ initial input on line. .TP .B \-p " prompt" prompt string. -.TP -.B \-r " resizecmd" -command to run on SIGWINCH (ncurses KEY_RESIZE). .SH BUGS Please report them! diff --git a/sob.c b/sob.c @@ -59,6 +59,7 @@ static int pipe_readline(int fd_in, int fd_out, char *writestr, char *outbuf, size_t outbufsiz); static int pipe_cmd(char *cmd[], char *writestr, char *outbuf, size_t outbufsiz); +static void resize(void); static void sighandler(int signum); static void setup(void); static void cleanup(void); @@ -99,7 +100,8 @@ line_inserttext(const char *s) } static void -line_set(const char *s) { +line_set(const char *s) +{ strlcpy(line.line, s, sizeof(line.line)); line.len = strlen(line.line); line.pos = line.len; @@ -496,6 +498,12 @@ setup(void) } static void +resize(void) +{ + line_pipeto((char **)resizecmd); +} + +static void cleanup(void) { endwin(); @@ -520,8 +528,7 @@ run(void) nodelay(win, FALSE); break; case KEY_RESIZE: - if(resizecmd && resizecmd[0]) - system(resizecmd); + resize(); break; default: ismatch = 0; @@ -545,8 +552,7 @@ run(void) static void usage(void) { - fprintf(stderr, "usage: %s <-f outfile> [-l line] [-p prompt] " - "[-r resizecmd]\n", argv0); + fprintf(stderr, "usage: %s <-f outfile> [-l line] [-p prompt]\n", argv0); exit(EXIT_FAILURE); } @@ -563,9 +569,6 @@ main(int argc, char **argv) case 'p': prompt = EARGF(usage()); break; - case 'r': - resizecmd = EARGF(usage()); - break; default: usage(); } ARGEND;