From 29b56ef4e4113bcd091b19d6926f18814162ca53 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 26 Oct 2021 21:01:41 -0700 Subject: Feat(libunicode): Added an explicit unicode library Refactored code to pull out utf8 functions from base into a standalone library. Also left the required function inside arg.c so that code that calls ARG_BEGIN doesn't have to link to libunicode. --- sys/cmd/dwm/dwm.h | 1 + sys/cmd/dwm/rules.mk | 3 ++- sys/cmd/menu/menu.h | 2 ++ sys/cmd/rc/exec.c | 2 +- sys/cmd/rc/input.c | 6 +++--- sys/cmd/rc/lex.c | 1 + sys/cmd/rc/prompt.c | 19 ++++++++++++++----- sys/cmd/rc/rc.h | 4 ++-- sys/cmd/term/rules.mk | 2 +- sys/cmd/term/term.h | 1 + 10 files changed, 28 insertions(+), 13 deletions(-) (limited to 'sys/cmd') diff --git a/sys/cmd/dwm/dwm.h b/sys/cmd/dwm/dwm.h index 269f373..9b616d1 100644 --- a/sys/cmd/dwm/dwm.h +++ b/sys/cmd/dwm/dwm.h @@ -2,6 +2,7 @@ #pragma once #include #include +#include #include #include diff --git a/sys/cmd/dwm/rules.mk b/sys/cmd/dwm/rules.mk index a87c3f6..f7254cd 100644 --- a/sys/cmd/dwm/rules.mk +++ b/sys/cmd/dwm/rules.mk @@ -21,7 +21,8 @@ $(BINS_$(d)): TCLIBS = \ `$(PKG) --libs fontconfig` \ `$(PKG) --libs freetype2` \ -lX11 -lXinerama -lXft -lX11-xcb -lxcb -lxcb-res -$(BINS_$(d)): $(OBJS_$(d)) $(OBJ_DIR)/sys/base/base.a + +$(BINS_$(d)): $(OBJS_$(d)) $(OBJ_DIR)/sys/libunicode/libunicode.a $(OBJ_DIR)/sys/base/base.a $(COMPLINK) include share/pop.mk diff --git a/sys/cmd/menu/menu.h b/sys/cmd/menu/menu.h index eaea274..8f1d6d7 100644 --- a/sys/cmd/menu/menu.h +++ b/sys/cmd/menu/menu.h @@ -1,6 +1,8 @@ /* See LICENSE file for copyright and license details. */ #include #include +#include + #include #include diff --git a/sys/cmd/rc/exec.c b/sys/cmd/rc/exec.c index 1b311ec..5baaf1a 100644 --- a/sys/cmd/rc/exec.c +++ b/sys/cmd/rc/exec.c @@ -914,7 +914,7 @@ Xreadcmd(void) flush(shell.err); root = runner; - shell.prompt = "> "; + resetprompt(); if(yyparse()){ // resource cleanup? diff --git a/sys/cmd/rc/input.c b/sys/cmd/rc/input.c index a89dbda..56f1780 100644 --- a/sys/cmd/rc/input.c +++ b/sys/cmd/rc/input.c @@ -309,11 +309,11 @@ refreshsingleline(struct TerminalState *term) char esc[64]; struct Buffer ab; - intptr plen = term->plen; + intptr plen = term->plen; int fd = term->ofd; char *buf = term->buf; - intptr len = term->len; - intptr pos = term->pos; + intptr len = term->len; + intptr pos = term->pos; while((plen+pos) >= term->cols) { buf++; diff --git a/sys/cmd/rc/lex.c b/sys/cmd/rc/lex.c index 596021b..9a58f21 100644 --- a/sys/cmd/rc/lex.c +++ b/sys/cmd/rc/lex.c @@ -52,6 +52,7 @@ readc(void) peek = EOF; return c; } + if(runner->flag.eof) return EOF; diff --git a/sys/cmd/rc/prompt.c b/sys/cmd/rc/prompt.c index d6846e6..6a32d59 100644 --- a/sys/cmd/rc/prompt.c +++ b/sys/cmd/rc/prompt.c @@ -1,21 +1,30 @@ #include "rc.h" +static char promptbuf[7] = {'>', ' ', 0, ' ' , ' ', ' ', 0}; + +void +resetprompt(void) +{ + promptbuf[2] = 0; +} int prompt(ushort *flag) { - int fd, f = *flag; + int f = *flag; + if(f){ - if(!readline(shell.prompt)){ + if(!readline(promptbuf)){ runner->flag.eof = 1; return 0; } - fd = mapfd(0); - write(fd, "\n\r", 2); - shell.prompt = "> "; // NOTE: can't use tab here: we have a hacky prompt length computation + write(mapfd(0), "\n\r", 2); + + promptbuf[2] = ' '; runner->line++; *flag = 0; } + return 1; } diff --git a/sys/cmd/rc/rc.h b/sys/cmd/rc/rc.h index 5a9aac5..eaf668a 100644 --- a/sys/cmd/rc/rc.h +++ b/sys/cmd/rc/rc.h @@ -152,7 +152,6 @@ struct Shell Io *err; int status; int interactive; - char *prompt; Thread *jobs; }; @@ -178,7 +177,8 @@ int readline(char *); void enablevi(void); /* prompt.c */ -int prompt(ushort *); +void resetprompt(void); +int prompt(ushort *); /* io.c */ Io *openfd(int fd); diff --git a/sys/cmd/term/rules.mk b/sys/cmd/term/rules.mk index a882e70..ef307c1 100644 --- a/sys/cmd/term/rules.mk +++ b/sys/cmd/term/rules.mk @@ -18,7 +18,7 @@ $(BINS_$(d)): TCLIBS = \ `$(PKG) --libs freetype2` \ -lm -lrt -lX11 -lutil -lXft -lXrender -lharfbuzz -$(BINS_$(d)): $(OBJS_$(d)) $(OBJ_DIR)/sys/base/base.a +$(BINS_$(d)): $(OBJS_$(d)) $(OBJ_DIR)/sys/libunicode/libunicode.a $(OBJ_DIR)/sys/base/base.a $(COMPLINK) include share/pop.mk diff --git a/sys/cmd/term/term.h b/sys/cmd/term/term.h index b328db7..3ff2852 100644 --- a/sys/cmd/term/term.h +++ b/sys/cmd/term/term.h @@ -3,6 +3,7 @@ #include #include +#include #include #include -- cgit v1.2.1