dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 61bd87f3ec1d6c0945e226ffa95314e7181aae06
parent 1ee40ba4b2496c42686cda5475e1632511d2d15d
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Thu, 23 Oct 2014 15:24:47 +0200

Cleanup vt_* API

Diffstat:
dvtm.c | 25++++++++++++++-----------
vt.c | 19++++++++++---------
vt.h | 52++++++++++++++++++++++++----------------------------
3 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/dvtm.c b/dvtm.c @@ -10,7 +10,10 @@ * * See LICENSE for details. */ - +#include <stdlib.h> +#include <unistd.h> +#include <stdint.h> +#include <wchar.h> #include <sys/select.h> #include <sys/stat.h> #include <sys/ioctl.h> @@ -438,7 +441,7 @@ focus(Client *c) { draw_border(c); wnoutrefresh(c->window); } - curs_set(!c->minimized && vt_cursor(c->term)); + curs_set(!c->minimized && vt_cursor_visible(c->term)); } static void @@ -457,12 +460,12 @@ applycolorrules(Client *c) { } } - vt_set_default_colors(c->term, attrs, fg, bg); + vt_default_colors_set(c->term, attrs, fg, bg); } static void term_title_handler(Vt *term, const char *title) { - Client *c = (Client *)vt_get_data(term); + Client *c = (Client *)vt_data_get(term); if (title) strncpy(c->title, title, sizeof(c->title) - 1); c->title[title ? sizeof(c->title) - 1 : 0] = '\0'; @@ -697,7 +700,7 @@ setup(void) { mouse_setup(); raw(); vt_init(); - vt_set_keytable(keytable, countof(keytable)); + vt_keytable_set(keytable, countof(keytable)); for (unsigned int i = 0; i < countof(colors); i++) { if (COLORS == 256) { if (colors[i].fg256) @@ -815,7 +818,7 @@ create(const char *args[]) { c->pid = vt_forkpty(c->term, "/bin/sh", pargs, cwd, env, NULL, NULL); if (args && args[2] && !strcmp(args[2], "$CWD")) free(cwd); - vt_set_data(c->term, c); + vt_data_set(c->term, c); vt_title_handler_set(c->term, term_title_handler); c->w = screen.w; c->h = screen.h; @@ -988,7 +991,7 @@ scrollback(const char *args[]) { vt_scroll(sel->term, sel->h/2); draw(sel); - curs_set(vt_cursor(sel->term)); + curs_set(vt_cursor_visible(sel->term)); } static void @@ -1491,7 +1494,7 @@ main(int argc, char *argv[]) { c = t; continue; } - int pty = c->editor ? vt_getpty(c->editor) : vt_getpty(c->app); + int pty = c->editor ? vt_pty_get(c->editor) : vt_pty_get(c->app); FD_SET(pty, &rd); nfds = max(nfds, pty); c = c->next; @@ -1541,8 +1544,8 @@ main(int argc, char *argv[]) { handle_statusbar(); for (Client *c = clients; c; c = c->next) { - bool ed = c->editor && FD_ISSET(vt_getpty(c->editor), &rd); - bool vt = FD_ISSET(vt_getpty(c->app), &rd); + bool ed = c->editor && FD_ISSET(vt_pty_get(c->editor), &rd); + bool vt = FD_ISSET(vt_pty_get(c->app), &rd); if (ed && vt_process(c->editor) < 0 && errno == EIO) { c->editor_died = true; @@ -1560,7 +1563,7 @@ main(int argc, char *argv[]) { if (is_content_visible(sel)) { draw_content(sel); - curs_set(vt_cursor(sel->term)); + curs_set(vt_cursor_visible(sel->term)); wnoutrefresh(sel->window); } } diff --git a/vt.c b/vt.c @@ -15,7 +15,9 @@ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - +#include <stdlib.h> +#include <stdint.h> +#include <unistd.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> @@ -81,7 +83,6 @@ #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define sstrlen(str) (sizeof(str) - 1) -#define COPYMODE_ATTR A_REVERSE static bool is_utf8, has_default_colors; static short color_pairs_reserved, color_pairs_max, color_pair_current; static short *color2palette, default_fg, default_bg; @@ -1170,7 +1171,7 @@ int vt_process(Vt *t) return 0; } -void vt_set_default_colors(Vt *t, attr_t attrs, short fg, short bg) +void vt_default_colors_set(Vt *t, attr_t attrs, short fg, short bg) { t->defattrs = attrs; t->deffg = fg; @@ -1517,7 +1518,7 @@ pid_t vt_forkpty(Vt *t, const char *p, const char *argv[], const char *cwd, cons return t->childpid = pid; } -int vt_getpty(Vt *t) +int vt_pty_get(Vt *t) { return t->pty; } @@ -1707,7 +1708,7 @@ void vt_init(void) strncat(vt_term, color_suffix, sizeof(color_suffix) - 1); } -void vt_set_keytable(const char * const keytable_overlay[], int count) +void vt_keytable_set(const char * const keytable_overlay[], int count) { for (int k = 0; k < count && k < KEY_MAX; k++) { const char *keyseq = keytable_overlay[k]; @@ -1726,19 +1727,19 @@ void vt_title_handler_set(Vt *t, vt_title_handler_t handler) t->title_handler = handler; } -void vt_set_data(Vt *t, void *data) +void vt_data_set(Vt *t, void *data) { t->data = data; } -void *vt_get_data(Vt *t) +void *vt_data_get(Vt *t) { return t->data; } -unsigned vt_cursor(Vt *t) +bool vt_cursor_visible(Vt *t) { - return t->buffer->scroll_below ? 0 : !t->curshid; + return t->buffer->scroll_below ? false : !t->curshid; } pid_t vt_pid_get(Vt *t) { diff --git a/vt.h b/vt.h @@ -15,17 +15,12 @@ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifndef VT_VT_H -#define VT_VT_H +#ifndef VT_H +#define VT_H #include <curses.h> #include <stdbool.h> -#include <stdint.h> -#include <stdlib.h> #include <sys/types.h> -#include <unistd.h> -#include <wchar.h> #ifndef NCURSES_MOUSE_VERSION #define mmask_t unsigned long @@ -35,36 +30,37 @@ typedef struct Vt Vt; typedef void (*vt_title_handler_t)(Vt*, const char *data); void vt_init(void); -void vt_set_keytable(char const * const keytable_overlay[], int count); void vt_shutdown(void); + +void vt_keytable_set(char const * const keytable_overlay[], int count); +void vt_default_colors_set(Vt*, attr_t attrs, short fg, short bg); void vt_title_handler_set(Vt*, vt_title_handler_t); -void vt_set_data(Vt *, void *); -void *vt_get_data(Vt *); -void vt_set_default_colors(Vt *, attr_t attrs, short fg, short bg); +void vt_data_set(Vt*, void *); +void *vt_data_get(Vt*); Vt *vt_create(int rows, int cols, int scroll_buf_sz); -void vt_resize(Vt *, int rows, int cols); -void vt_destroy(Vt *); -pid_t vt_forkpty(Vt *, const char *p, const char *argv[], const char *cwd, const char *env[], int *to, int *from); -int vt_getpty(Vt *); -unsigned vt_cursor(Vt *t); +void vt_resize(Vt*, int rows, int cols); +void vt_destroy(Vt*); +pid_t vt_forkpty(Vt*, const char *p, const char *argv[], const char *cwd, const char *env[], int *to, int *from); +int vt_pty_get(Vt*); +bool vt_cursor_visible(Vt*); int vt_process(Vt *); void vt_keypress(Vt *, int keycode); -int vt_write(Vt *t, const char *buf, int len); -void vt_mouse(Vt *t, int x, int y, mmask_t mask); -void vt_dirty(Vt *t); -void vt_draw(Vt *, WINDOW *win, int startrow, int startcol); -short vt_color_get(Vt *t, short fg, short bg); +int vt_write(Vt*, const char *buf, int len); +void vt_mouse(Vt*, int x, int y, mmask_t mask); +void vt_dirty(Vt*); +void vt_draw(Vt*, WINDOW *win, int startrow, int startcol); +short vt_color_get(Vt*, short fg, short bg); short vt_color_reserve(short fg, short bg); -void vt_scroll(Vt *, int rows); -void vt_noscroll(Vt *); +void vt_scroll(Vt*, int rows); +void vt_noscroll(Vt*); -void vt_bell(Vt *, bool bell); -void vt_togglebell(Vt *); +void vt_bell(Vt*, bool bell); +void vt_togglebell(Vt*); -pid_t vt_pid_get(Vt *t); -size_t vt_content_get(Vt *t, char **s); +pid_t vt_pid_get(Vt*); +size_t vt_content_get(Vt*, char **s); -#endif /* VT_VT_H */ +#endif /* VT_H */