sex

simple editor extended using libtermbox
git clone git://z3bra.org/sex
Log | Files | Refs | README

commit 9aa344e4aa1683103da76be0df09abd9b6f461c8
parent dcdb608624245c647451aae016c041669f8fe156
Author: z3bra <willyatmailoodotorg>
Date:   Sun Apr  3 22:54:41 2016

Cosmetic changes

Rename function for the UI as ui_* instead of tb_*.
Rename struct ln_s to line_s, for consistency sake.

Diffstat:
 sex.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/sex.c b/sex.c @@ -15,10 +15,10 @@ #define TAB_WIDTH 8 -struct ln_s { +struct line_s { char *p; size_t len; - TAILQ_ENTRY(ln_s) entries; + TAILQ_ENTRY(line_s) entries; }; struct file_s { @@ -27,12 +27,12 @@ struct file_s { char *p; size_t size; int d; - struct ln_s *ln; + struct line_s *ln; }; static struct file_s f; -TAILQ_HEAD(ln_s_head, ln_s) head; -struct ln_s *cur; +TAILQ_HEAD(line_s_head, line_s) head; +struct line_s *cur; void cleanup(void) @@ -57,7 +57,7 @@ open_file(char *path) size_t i, last_eol; int d; struct stat s; - struct ln_s *tmp; + struct line_s *tmp; f.path = path; @@ -94,7 +94,7 @@ open_file(char *path) } ssize_t -tb_expand_tab(int x, int y, uint8_t tw) +ui_expand_tab(int x, int y, uint8_t tw) { uint8_t i, tabsize = 0; @@ -106,7 +106,7 @@ tb_expand_tab(int x, int y, uint8_t tw) } void -tb_print(char *str, int x, int y, int len) { +ui_print(char *str, int x, int y, int len) { int n = 0; while (*str) { @@ -114,7 +114,7 @@ tb_print(char *str, int x, int y, int len) { switch(*str) { case '\t': - x += tb_expand_tab(x, y, TAB_WIDTH); + x += ui_expand_tab(x, y, TAB_WIDTH); str++; break; default: @@ -129,14 +129,15 @@ tb_print(char *str, int x, int y, int len) { } void -tb_redraw(void) { +ui_redraw(void) { /* redraw screen */ - struct ln_s *tmp; + struct line_s *tmp; int i = 0; TAILQ_FOREACH(tmp, &head, entries) { - tb_print(tmp->p, 0, i++, tmp->len); + ui_print(tmp->p, 0, i++, tmp->len); } + tb_present(); } @@ -147,7 +148,7 @@ edit(char *path) struct tb_event ev; open_file(path); - tb_redraw(); + ui_redraw(); while (tb_poll_event(&ev)) { switch (ev.type) { @@ -167,7 +168,7 @@ edit(char *path) } if (needs_redraw) { - tb_redraw(); + ui_redraw(); needs_redraw = 0; } }