From 660958f3bb1608408217f9315bd0ef2f4a90e815 Mon Sep 17 00:00:00 2001 From: josuah Date: Sun, 27 Nov 2016 13:26:21 +0100 Subject: [PATCH] Fixed line drawing --- draw.c | 47 +++++++++++++++++--------------- io-abduco | 2 +- nohup.out | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 23 deletions(-) create mode 100644 nohup.out diff --git a/draw.c b/draw.c index e18023b..0dfc93b 100644 --- a/draw.c +++ b/draw.c @@ -10,44 +10,47 @@ * Print a line to stderr. */ void -draw_line(Line *line, int current, int cols, Opt *opt) +draw_line(Line *line, int current, const int cols, Opt *opt) { char *content = expand_tabs(line->content); char *comment = expand_tabs(line->comment); - char output[LINE_SIZE * sizeof(char)] = ""; + char output[LINE_SIZE * sizeof(char)] = "\033[K"; + int n = 0; - /* clear the line */ - strncat(output, "\033[K", cols); - - if (!line->header) - strncat(output, current ? "\033[1;31m>" : " ", cols--); + if (!line->header) { + strcat(output, current ? "\033[1;31m>" : " "); + n++; + } if (opt->line_numbers) { strcat(output, current ? "\033[1;37m" : "\033[1;30m"); - sprintf(output, "%7d \033[0m", line->number); - cols -= 8; + sprintf(output + strlen(output), "%7d \033[0m", line->number); + n += 8; } else { - strncat(output, " ", cols--); + strcat(output, " "); + n++; } /* highlight current line */ if (current) - strcat(output, "\033[1;33m"); + strcat(output, "\033[1;32m"); - /* print content without overflowing terminal width */ - strncat(output, content, cols); - cols -= strlen(content); + /* content */ + strncat(output, content, cols - n); + n += strlen(content); - /* shift without overflowing terminal width */ + /* align comment */ if (!line->header && line->comment[0] != '\0') { /* MAX with '1' as \033[0C still move 1 to the right */ - sprintf(content, "\033[%dC\033[1;30m", MAX(MIN(40, cols), 1)); - cols -= MAX(MIN(40, cols), 1); - } - - /* print comment without overflowing terminal width */ - strncat(output, comment, cols); - cols -= strlen(comment); + sprintf(output + strlen(output), "\033[%dC", + MAX(1, 40 - n)); + n += MAX(1, 40 - n); + } else if (line->header) + + /* comment */ + strcat(output, "\033[1;30m"); + strncat(output, comment, cols - n); + n += strlen(comment); strcat(output, "\033[0m\n"); diff --git a/io-abduco b/io-abduco index d0728f1..d847fe2 100755 --- a/io-abduco +++ b/io-abduco @@ -1,4 +1,4 @@ -# Detacheable buffer for programs and files +# detacheable buffer for programs and files using abduco CACHE="${XDG_CACHE_HOME:-$HOME/.cache}" diff --git a/nohup.out b/nohup.out new file mode 100644 index 0000000..f4a5828 --- /dev/null +++ b/nohup.out @@ -0,0 +1,92 @@ +build: Installing tmux +checking for a BSD-compatible install... /usr/bin/install -c +checking whether build environment is sane... yes +checking for a thread-safe mkdir -p... /bin/mkdir -p +checking for gawk... no +checking for mawk... mawk +checking whether make sets $(MAKE)... yes +checking whether make supports nested variables... yes +checking build system type... x86_64-unknown-linux-gnu +checking host system type... x86_64-unknown-linux-gnu +checking for gcc... gcc +checking whether the C compiler works... yes +checking for C compiler default output file name... a.out +checking for suffix of executables... +checking whether we are cross compiling... no +checking for suffix of object files... o +checking whether we are using the GNU C compiler... yes +checking whether gcc accepts -g... yes +checking for gcc option to accept ISO C89... none needed +checking whether gcc understands -c and -o together... yes +checking for style of include used by make... GNU +checking dependency style of gcc... gcc3 +checking how to run the C preprocessor... gcc -E +checking for grep that handles long lines and -e... /bin/grep +checking for egrep... /bin/grep -E +checking for pkg-config... /usr/bin/pkg-config +checking pkg-config is at least version 0.9.0... yes +checking for glibc... yes +checking for ANSI C header files... yes +checking for sys/types.h... yes +checking for sys/stat.h... yes +checking for stdlib.h... yes +checking for string.h... yes +checking for memory.h... yes +checking for strings.h... yes +checking for inttypes.h... yes +checking for stdint.h... yes +checking for unistd.h... yes +checking bitstring.h usability... no +checking bitstring.h presence... no +checking for bitstring.h... no +checking dirent.h usability... yes +checking dirent.h presence... yes +checking for dirent.h... yes +checking fcntl.h usability... yes +checking fcntl.h presence... yes +checking for fcntl.h... yes +checking for inttypes.h... (cached) yes +checking libutil.h usability... no +checking libutil.h presence... no +checking for libutil.h... no +checking ndir.h usability... no +checking ndir.h presence... no +checking for ndir.h... no +checking paths.h usability... yes +checking paths.h presence... yes +checking for paths.h... yes +checking pty.h usability... yes +checking pty.h presence... yes +checking for pty.h... yes +checking for stdint.h... (cached) yes +checking sys/dir.h usability... yes +checking sys/dir.h presence... yes +checking for sys/dir.h... yes +checking sys/ndir.h usability... no +checking sys/ndir.h presence... no +checking for sys/ndir.h... no +checking sys/tree.h usability... no +checking sys/tree.h presence... no +checking for sys/tree.h... no +checking term.h usability... no +checking term.h presence... no +checking for term.h... no +checking util.h usability... no +checking util.h presence... no +checking for util.h... no +checking for library containing flock... none required +checking for dirfd... yes +checking for flock... yes +checking for prctl... yes +checking for sysconf... yes +checking for cfmakeraw... yes +checking for library containing clock_gettime... none required +checking for LIBEVENT... no +checking for library containing event_init... no +checking event.h usability... no +checking event.h presence... no +checking for event.h... no +configure: error: "libevent not found" +make: *** No rule to make target 'install'. Stop. +build: Updating index in /home/josuah/.local/tmux +build: Removing broken links from /home/josuah/.local -- 2.11.4.GIT