From 58716e08fd3ce62861636a300879e10e930b177b Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 10 Oct 2012 13:05:24 +0800 Subject: [PATCH] libc+AxWin3 - RichText rendering, scanf --- Makefile | 2 +- .../Applications/axwin3_src/Interface/main.c | 5 +- .../axwin3_src/WM/renderers/richtext.c | 3 +- Usermode/Libraries/libc.so_src/Makefile | 2 +- .../Libraries/libc.so_src/include_exp/stdio.h | 8 +++ Usermode/Libraries/libc.so_src/scanf.c | 71 +++++++++++++++++++ 6 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 Usermode/Libraries/libc.so_src/scanf.c diff --git a/Makefile b/Makefile index e16a7b24..1d05b1a4 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ USRLIBS += libimage_sif.so USRAPPS := init login CLIShell cat ls mount USRAPPS += bomb lspci USRAPPS += ip dhcpclient ping telnet irc wget telnetd -USRAPPS += axwin3 +USRAPPS += axwin3 gui_ate ALL_DYNMODS = $(addprefix all-,$(DYNMODS)) ALL_MODULES := $(addprefix all-,$(MODULES)) diff --git a/Usermode/Applications/axwin3_src/Interface/main.c b/Usermode/Applications/axwin3_src/Interface/main.c index fee178ac..5a8fe08e 100644 --- a/Usermode/Applications/axwin3_src/Interface/main.c +++ b/Usermode/Applications/axwin3_src/Interface/main.c @@ -51,8 +51,8 @@ int main(int argc, char *argv[]) create_run_dialog(); AxWin3_RegisterAction(gSidebar, "Interface>Run", (tAxWin3_HotkeyCallback)mainmenu_run_dialog); -// AxWin3_RegisterAction(gSidebar, "Interface>Terminal", mainmenu_app_terminal); -// AxWin3_RegisterAction(gSidebar, "Interface>TextEdit", mainmenu_app_textedit); + AxWin3_RegisterAction(gSidebar, "Interface>Terminal", (tAxWin3_HotkeyCallback)mainmenu_app_terminal); + AxWin3_RegisterAction(gSidebar, "Interface>TextEdit", (tAxWin3_HotkeyCallback)mainmenu_app_textedit); // Idle loop AxWin3_MainLoop(); @@ -108,6 +108,7 @@ void create_sidebar(void) void mainmenu_app_textedit(void *unused) { _SysDebug("TODO: Launch text editor"); +// spawn("/Acess/Apps/AxWin/3.0/ate"); } void mainmenu_app_terminal(void *unused) diff --git a/Usermode/Applications/axwin3_src/WM/renderers/richtext.c b/Usermode/Applications/axwin3_src/WM/renderers/richtext.c index ecdb40e9..9ad384c3 100644 --- a/Usermode/Applications/axwin3_src/WM/renderers/richtext.c +++ b/Usermode/Applications/axwin3_src/WM/renderers/richtext.c @@ -8,6 +8,7 @@ #include #include #include +#include // sscanf #define LINES_PER_BLOCK 30 @@ -63,7 +64,7 @@ tWindow *Renderer_RichText_Create(int Flags) return ret; } -inline int Renderer_RichText_RenderText_Act(tWindow *Window, tRichText_Window *info, int X, int Row, const char *Text, int Bytes, tColour FG, tColour BG) +static inline int Renderer_RichText_RenderText_Act(tWindow *Window, tRichText_Window *info, int X, int Row, const char *Text, int Bytes, tColour FG, tColour BG) { int rwidth; // TODO: Fill only what is needed diff --git a/Usermode/Libraries/libc.so_src/Makefile b/Usermode/Libraries/libc.so_src/Makefile index 6484897b..defdb58a 100644 --- a/Usermode/Libraries/libc.so_src/Makefile +++ b/Usermode/Libraries/libc.so_src/Makefile @@ -11,7 +11,7 @@ LDFLAGS += -soname libc.so -Map map.txt -lgcc INCFILES := stdio.h stdlib.h OBJ = stub.o heap.o stdlib.o env.o fileIO.o string.o select.o rand.o -OBJ += perror.o +OBJ += perror.o scanf.o OBJ += arch/$(ARCHDIR).ao # signals.o DEPFILES := $(OBJ:%.o=%.d) diff --git a/Usermode/Libraries/libc.so_src/include_exp/stdio.h b/Usermode/Libraries/libc.so_src/include_exp/stdio.h index faf20f0e..d8643eb0 100644 --- a/Usermode/Libraries/libc.so_src/include_exp/stdio.h +++ b/Usermode/Libraries/libc.so_src/include_exp/stdio.h @@ -45,6 +45,14 @@ extern int putchar(int ch); extern int fprintf(FILE *fp, const char *format, ...); extern int vfprintf(FILE *fp, const char *format, va_list args); +// scanf +extern int scanf(const char *format, ...); +extern int fscanf(FILE *stream, const char *format, ...); +extern int sscanf(const char *str, const char *format, ...); +extern int vscanf(const char *format, va_list ap); +extern int vsscanf(const char *str, const char *format, va_list ap); +extern int vfscanf(FILE *stream, const char *format, va_list ap); + extern FILE *stdin; extern FILE *stdout; extern FILE *stderr; diff --git a/Usermode/Libraries/libc.so_src/scanf.c b/Usermode/Libraries/libc.so_src/scanf.c new file mode 100644 index 00000000..196ef3dc --- /dev/null +++ b/Usermode/Libraries/libc.so_src/scanf.c @@ -0,0 +1,71 @@ +/* + * Acess2 C Library + * - By John Hodge (thePowersGang) + * + * scanf.c + * - *scanf family of functions + */ +#include +#include + +// === CODE === +int _vcscanf(int (*__getc)(void *), void *h, const char *format, va_list ap) +{ + // TODO: Impliment + return 0; +} + +int _vsscanf_getc(void *h) +{ + const char **ibuf = h; + return *(*ibuf)++; // Dereference, read, increment +} + +int vscanf(const char *format, va_list ap) +{ + return vfscanf(stdin, format, ap); +} + +int vsscanf(const char *str, const char *format, va_list ap) +{ + return _vcscanf(_vsscanf_getc, &str, format, ap); +} + +int _vfscanf_getc(void *h) +{ + return fgetc(h); // TODO: Handle -1 -> 0 +} + +int vfscanf(FILE *stream, const char *format, va_list ap) +{ + return _vcscanf(_vfscanf_getc, stream, format, ap); +} + +int scanf(const char *format, ...) +{ + va_list args; + int rv; + va_start(args, format); + rv = vfscanf(stdin, format, args); + va_end(args); + return rv; +} +int fscanf(FILE *stream, const char *format, ...) +{ + va_list args; + int rv; + va_start(args, format); + rv = vfscanf(stream, format, args); + va_end(args); + return rv; +} +int sscanf(const char *str, const char *format, ...) +{ + va_list args; + int rv; + va_start(args, format); + rv = vsscanf(str, format, args); + va_end(args); + return rv; +} + -- 2.20.1