diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index c4ad25a9..f7c24889 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -321,7 +321,6 @@ jobs: run: | git clean -x -d -f . mingw32-make -f makefile.msys git.c - rm libloc.c - name: Download PDF manual uses: actions/download-artifact@v4.1.7 with: diff --git a/.gitignore b/.gitignore index 5c0bcd6d..78d247e4 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,9 @@ Makefile.in *.exe git.c logo_win.res +.vscode/browse.* +.* +*~ +*.swp + + diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..9d0858df --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,111 @@ +{ + "env": { + "myIncludePath": [ + "${workspaceFolder}", + "/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.0", + "/usr/include/wx-3.0" + ] + }, + "configurations": [ + { + "name": "Linux", + "compilerPath": "/usr/bin/gcc", + "compilerArgs": [], + "includePath": [ + "${myIncludePath}" + ], + "defines": [ + "HAVE_CONFIG_H", + "_FILE_OFFSET_BITS=64", + "WXUSINGDLL", + "__WXGTK__" + ], + "cStandard": "c90", + "cppStandard": "gnu++14", + "configurationProvider": "ms-vscode.cmake-tools", + "forcedInclude": [], + "compileCommands": [], + "dotConfig": "${workspaceFolder}/.config", + "mergeConfigurations": true, + "customConfigurationVariables": { + "myVar": "myvalue" + }, + "browse": { + "path": [ + "${myIncludePath}", + "/usr/include", + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db" + } + }, + { + "name": "win32", + "compilerPath": "/usr/bin/gcc", + "compilerArgs": [], + "includePath": [ + "${workspaceFolder}/**", + "${myIncludePath}" + ], + "defines": [ + "WIN32", + "HAVE_WX", + "HAVE_CONFIG_C", + "X_DISPLAY_MISSING", + "__WXDEBUG__", + "__WXMSW__" + ], + "cStandard": "c90", + "cppStandard": "gnu++14", + "configurationProvider": "ms-vscode.cmake-tools", + "forcedInclude": [], + "compileCommands": [], + "dotConfig": "${workspaceFolder}/.config", + "mergeConfigurations": true, + "customConfigurationVariables": { + "myVar": "myvalue" + }, + "browse": { + "path": [ + "${myIncludePath}", + "/usr/include", + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db" + } + }, + { + "name": "dos", + "compilerPath": "/usr/bin/gcc", + "compilerArgs": [], + "includePath": [ + "${myIncludePath}" + ], + "defines": [ + "__TURBOC__" + ], + "cStandard": "c90", + "cppStandard": "gnu++14", + "configurationProvider": "ms-vscode.cmake-tools", + "forcedInclude": [], + "compileCommands": [], + "dotConfig": "${workspaceFolder}/.config", + "mergeConfigurations": true, + "customConfigurationVariables": { + "myVar": "myvalue" + }, + "browse": { + "path": [ + "${myIncludePath}", + "/usr/include", + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db" + } + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..d524b073 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,31 @@ +{ + "C_Cpp.default.compilerPath": "C:/msys64/mingw32/bin/gcc.exe", + "terminal.integrated.profiles.windows": { + "MSYS2": { + "path": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "--login", + "-i" + ], + "env": { + "MSYSTEM": "MINGW64", + "CHERE_INVOKING": "1", + "MINGW_CHOST": "x86_64-w64-mingw32", + "MINGW_PACKAGE_PREFIX": "mingw-w64-x86_64", + "MSYSTEM_CARCH": "x86_64", + "MSYSTEM_CHOST": "x86_64-w64-mingw32", + "PS1": "\\[\\e]0;\\w\\a\\]\\n\\[\\e[32m\\]\\u@\\h \\[\\e[35m\\]$MSYSTEM\\[\\e[0m\\] \\[\\e[33m\\]\\w\\[\\e[0m\\]\\n\\$", + "MSYSCON": "mintty.exe", + "MSYSTEM_PREFIX": "/mingw64", + "PKG_CONFIG_SYSTEM_INCLUDE_PATH": "/mingw64/include", + "PKG_CONFIG_PATH": "/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig", + "MANPATH": "/mingw64/local/man:/mingw64/share/man:/usr/local/man:/usr/share/man:/usr/man:/share/man", + "INFOPATH": "/mingw64/local/info:/mingw64/share/info:/usr/local/info:/usr/share/info:/usr/info:/share/info", + "ACLOCAL_PATH": "/mingw64/share/aclocal:/usr/share/aclocal", + "PKG_CONFIG_SYSTEM_LIBRARY_PATH": "/mingw64/lib", + "XDG_DATA_DIRS": "/mingw64/share/:/usr/local/share/:/usr/share/", + "PATH": "/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl", + } + } + } +} \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index d0d7aa38..443c6928 100644 --- a/Makefile.am +++ b/Makefile.am @@ -92,9 +92,6 @@ EXTRA_DIST += changes.txt config.h.msys diffscript.pl .gitignore \ # Diagram of evaluator, in three formats because hey why not EXTRA_DIST += evaluator.ps evaluator.pdf evaluator.svg -# Win32 API compliant graphics routines (unused) -EXTRA_DIST += win32trm.c win32trm.h - # makehelp_SOURCES = makehelp.c # Make sure pdf built for distributions diff --git a/coms.c b/coms.c index d98024b5..004f4e16 100644 --- a/coms.c +++ b/coms.c @@ -35,17 +35,6 @@ extern int check_wx_stop(int force_yield, int pause_return_value); #include #endif -#ifdef HAVE_TERMIO_H -#ifdef HAVE_WX -#include -#else -#include -#endif -#else -#ifdef HAVE_SGTTY_H -#include -#endif -#endif #ifdef HAVE_GETTIMEOFDAY #include @@ -378,15 +367,8 @@ NODE *lwait(NODE *args) { return(UNBOUND); #endif*/ #ifndef HAVE_WX -#ifdef WIN32 - win32_update_text(); -#else fflush(stdout); /* csls v. 1 p. 7 */ #endif -#else - //doesn't seem to work in WX. now done in wxLogoSleep - //fflush(stdout); /* csls v. 1 p. 7 */ -#endif fix_turtle_shownness(); @@ -409,13 +391,6 @@ NODE *lwait(NODE *args) { n = (unsigned int)getint(num) / 60; sleep(n); #endif -#else /* unreachable, I think */ - if (!setjmp(iblk_buf)) { - input_blocking++; - n = ((unsigned int)getint(num)+30) / 60; - if (n > 0) sleep(n); - } - input_blocking = 0; #endif /* unix */ } #endif /* HAVE_WX */ diff --git a/configure.ac b/configure.ac index 466e7860..6794075d 100644 --- a/configure.ac +++ b/configure.ac @@ -104,9 +104,7 @@ AM_COND_IF([X11], [AC_SEARCH_LIBS(XOpenDisplay, [X11])]) dnl Checks for header files. -AC_CHECK_HEADERS([unistd.h string.h]) -AM_COND_IF([WX],, - [AC_CHECK_HEADERS([sgtty.h termio.h termcap.h termlib.h curses.h])]) +AC_CHECK_HEADERS([termios.h termio.h termcap.h termlib.h curses.h sys/ioctl.h unistd.h string.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T diff --git a/error.c b/error.c index 46975c34..4c3ee0bd 100644 --- a/error.c +++ b/error.c @@ -26,16 +26,14 @@ #include "logo.h" #include "globals.h" -#ifdef HAVE_TERMIO_H -#ifdef HAVE_WX +#if defined(HAVE_TERMIOS_H) #include -#else +#elif defined(HAVE_TERMIO_H) #include #endif -#else -#ifdef HAVE_SGTTY_H -#include -#endif + +#ifdef HAVE_SYS_IOCTL_H +#include #endif #ifdef HAVE_UNISTD_H @@ -264,18 +262,12 @@ void memcpy(char *to, char *from, size_t len) { NODE *lpause(NODE *args) { NODE *elist = NIL, *val = UNBOUND, *uname = NIL; int sav_input_blocking; -#ifndef TIOCSTI - jmp_buf sav_iblk; -#endif if (err_mesg != NIL) err_print(NULL); ndprintf(stdout, "%t\n", message_texts[PAUS_ING]); if (inside_evaluator) { uname = ufun; ufun = NIL; -#ifndef TIOCSTI - memcpy((char *)(&sav_iblk), (char *)(&iblk_buf), sizeof(jmp_buf)); -#endif sav_input_blocking = input_blocking; input_blocking = 0; while (RUNNING) { @@ -292,10 +284,6 @@ NODE *lpause(NODE *args) { val = output_node; output_node = UNBOUND; stopping_flag = RUN; -#ifndef TIOCSTI - memcpy((char *)(&iblk_buf), (char *)(&sav_iblk), - sizeof(jmp_buf)); -#endif input_blocking = sav_input_blocking; if (uname != NIL) { ufun = uname; @@ -307,9 +295,6 @@ NODE *lpause(NODE *args) { } } } -#ifndef TIOCSTI - memcpy((char *)(&iblk_buf), (char *)(&sav_iblk), sizeof(jmp_buf)); -#endif input_blocking = sav_input_blocking; unblock_input(); if (uname != NIL) { diff --git a/eval.c b/eval.c index c6755bc5..1e14db5a 100644 --- a/eval.c +++ b/eval.c @@ -109,18 +109,6 @@ void debprintline(int line, char *name) { #define DEB_CONT 0 #endif -#ifdef HAVE_TERMIO_H -#ifdef HAVE_WX -#include -#else -#include -#endif -#else -#ifdef HAVE_SGTTY_H -#include -#endif -#endif - #if DEB_STACK NODE *restname, *restline; #define save(register) ( debprint2("saving " #register " = %s ", register), \ diff --git a/files.c b/files.c index 38dcca1f..78e0ae0c 100644 --- a/files.c +++ b/files.c @@ -38,16 +38,14 @@ int reading_char_now = 0; #define sysUnGetC ungetc #endif -#ifdef HAVE_TERMIO_H -#ifdef HAVE_WX +#if defined(HAVE_TERMIOS_H) #include -#else +#elif defined(HAVE_TERMIO_H) #include #endif -#else -#ifdef HAVE_SGTTY_H -#include -#endif + +#ifdef HAVE_SYS_IOCTL_H +#include #endif #ifdef HAVE_UNISTD_H @@ -466,7 +464,6 @@ void silent_load(NODE *arg, const char *prefix) { for (cp = load_path; *cp != '\0'; cp++) if (*cp == '?') *cp = 'Q'; } - /* strcpy(load_path, eight_dot_three(load_path)); */ /* #endif */ } tmp_stream = loadstream; @@ -577,9 +574,6 @@ NODE *lreadchar(NODE *args) { } charmode_on(); input_blocking++; -#ifndef TIOCSTI - if (!setjmp(iblk_buf)) -#endif { #ifdef HAVE_WX if (interactive && readstream==stdin) { @@ -616,9 +610,6 @@ NODE *lreadchars(NODE *args) { if (stopping_flag == THROWING) return UNBOUND; charmode_on(); input_blocking++; -#ifndef TIOCSTI - if (!setjmp(iblk_buf)) -#endif { strhead = malloc((size_t)(c + sizeof(FIXNUM) + 1)); if (strhead == NULL) { @@ -642,9 +633,6 @@ NODE *lreadchars(NODE *args) { setstrrefcnt(strhead, 0); } input_blocking = 0; -#ifndef TIOCSTI - if (stopping_flag == THROWING) return(UNBOUND); -#endif if (c <= 0) { free(strhead); return(NIL); diff --git a/globals.h b/globals.h index fe1ddefb..b97d1b68 100644 --- a/globals.h +++ b/globals.h @@ -43,11 +43,6 @@ void mouse_down(void); #define mouse_click mouse_down() #endif -#ifndef TIOCSTI -#include -extern jmp_buf iblk_buf; -#endif - /* logodata.c */ extern char *strnzcpy(char *, char *, int); extern char *word_strnzcpy(char *, char *, int); @@ -594,8 +589,6 @@ extern int clearing_screen; #endif #ifdef WIN32 -/* Win32trm.c */ - #undef WIN32_DEBUG #undef CONSOLE @@ -608,26 +601,13 @@ extern void WinDebug(char *); extern char *read_line, buffered_char; extern int char_mode; extern int line_avail, char_avail; -extern void win32_advance_line(void); -extern char *eight_dot_three(char *); -extern BOOLEAN check_ibm_stop(void); -extern NODE* win32_lsetcursor(NODE *); -extern int win32_putc(int, FILE*); extern void win32_charmode_off(void), win32_charmode_on(void); -extern void win32_repaint_screen(void); -extern void win32_clear_text(void); -extern void ibm_plain_mode(void); -extern void ibm_bold_mode(void); extern void win32_update_text(void); -extern void moveto(int, int); -extern void lineto(int, int); extern void draw_string(char *); -extern int win32_screen_bottom(void); extern void win32_text_cursor(void); extern NODE *set_text_color(NODE *); extern void winDoPaste(void); extern char *winPasteText; -extern NODE *maximize(NODE *); #define SIGQUIT SIGABRT @@ -636,12 +616,8 @@ extern NODE *maximize(NODE *); #ifdef HAVE_WX #define rd_putc printToScreen #else -#ifdef WIN32 -#define rd_putc win32_putc -#else /* !WIN32 */ #define rd_putc putc #endif -#endif #ifdef OBJECTS /* obj.c */ diff --git a/graphics.c b/graphics.c index b5b081b1..d9ea5744 100644 --- a/graphics.c +++ b/graphics.c @@ -34,8 +34,6 @@ #ifdef HAVE_WX #include "wxGraphics.h" -#elif defined(WIN32) -#include "win32trm.h" #elif defined(x_window) #include "xgraphics.h" #else diff --git a/init.c b/init.c index 9b15d379..07b80e65 100644 --- a/init.c +++ b/init.c @@ -254,11 +254,6 @@ PRIMTYPE prims[] = { {"macrop", 1, 1, 1, PREFIX_PRIORITY, lmacrop}, {"macro?", 1, 1, 1, PREFIX_PRIORITY, lmacrop}, {"make", 2, 2, 2, PREFIX_PRIORITY, lmake}, -#ifndef HAVE_WX -#if defined(WIN32) - {"maximize.window", 1, 1, 1, PREFIX_PRIORITY, maximize}, -#endif -#endif {"member", 2, 2, 2, PREFIX_PRIORITY, lmember}, {"memberp", 2, 2, 2, PREFIX_PRIORITY, lmemberp}, {"member?", 2, 2, 2, PREFIX_PRIORITY, lmemberp}, @@ -407,11 +402,9 @@ PRIMTYPE prims[] = { {"setread", 1, 1, 1, PREFIX_PRIORITY, lsetread}, {"setreadpos", 1, 1, 1, PREFIX_PRIORITY, lsetreadpos}, {"setscrunch", 2, 2, 2, PREFIX_PRIORITY, lsetscrunch}, -#if defined(WIN32)|defined(HAVE_WX) +#if defined(HAVE_WX) {"settc", 2, 2, 2, PREFIX_PRIORITY, set_text_color}, {"settextcolor", 2, 2, 2, PREFIX_PRIORITY, set_text_color}, -#endif -#ifdef HAVE_WX {"settextsize", 1, 1, 1, PREFIX_PRIORITY, lsettextsize}, #endif {"settemploc", 1, 1, 1, PREFIX_PRIORITY, lsettemploc}, diff --git a/main.c b/main.c index e74330dc..9b70a8bb 100644 --- a/main.c +++ b/main.c @@ -30,23 +30,16 @@ #include "logo.h" #include "globals.h" -#ifdef HAVE_TERMIO_H -#ifdef HAVE_WX +#if defined(HAVE_TERMIOS_H) #include -#else +#elif defined(HAVE_TERMIO_H) #include #endif -#else -#ifdef HAVE_SGTTY_H -#include -#endif -#endif -#ifndef TIOCSTI -#include -jmp_buf iblk_buf; +#ifdef HAVE_SYS_IOCTL_H +#include #endif - + #ifdef HAVE_UNISTD_H #include #endif @@ -60,10 +53,8 @@ int stop_quietly_flag=0; void unblock_input(void) { if (input_blocking) { input_blocking = 0; -#ifdef TIOCSTI +#ifdef HAVE_IOCTRL_H ioctl(0,TIOCSTI,"\n"); -#else - longjmp(iblk_buf,1); #endif } } diff --git a/makefile.msys b/makefile.msys index 9b04882e..4301a509 100644 --- a/makefile.msys +++ b/makefile.msys @@ -1,5 +1,16 @@ +prefix = /c/ucblogo +LIBLOC = $(prefix)/lib/logo +LOGOLIBLOC = $(LIBLOC)/logolib +HELPLOC = $(LIBLOC)/helpfiles +CSLSLOC = $(LIBLOC)/csls +TEMPLOC = /tmp + CC = gcc -CFLAGS = -g -O -DHAVE_CONFIG_H -DHAVE_WX -DX_DISPLAY_MISSING -O0 +CFLAGS = -save-temps -g -O -DHAVE_CONFIG_H -DHAVE_WX -DX_DISPLAY_MISSING -O0 \ + -DLIBLOC='"$(LOGOLIBLOC)"' \ + -DHELPLOC='"$(HELPLOC)"' \ + -DCSLSLOC='"$(CSLSLOC)"' \ + -DTEMPLOC='"/tmp"' CXX = g++ MINGW_BIN_DIR = /mingw/bin WX_DIR = $(HOME)/wxWidgets-3.2.2.1 @@ -7,9 +18,7 @@ CXXFLAGS = -DHAVE_CONFIG_H -DHAVE_WX -I$(WX_DIR)/include -I$(WX_DIR)/lib/gcc_li LDFLAGS = -mwindows WX_LIB_LOC = $(WX_DIR)/lib/gcc_lib/ LIBS = -lm -L/usr/local/lib -mwindows -mthreads -mwindows -Wl,--subsystem,windows -mwindows -L$(WX_LIB_LOC) -lwxmsw32u_richtext -lwxmsw32u_aui -lwxmsw32u_html -lwxmsw32u_adv -lwxmsw32u_core -lwxbase32u_net -lwxbase32u -lwxregexu -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32 -lversion -lshlwapi -luxtheme -loleacc -prefix = /c/ucblogo BINDIR = $(prefix)/bin -LIBLOC = $(prefix)/lib/logo LINKER = $(CXX) # LIBLOC = `pwd` @@ -45,13 +54,6 @@ tags: $(SRCS) ctags --format=1 -N $(SRCS) $(HDRS) # ctags -t $(SRCS) $(HDRS) -libloc.c: - echo 'char *libloc="'$(LIBLOC)'/logolib";' > libloc.c - echo 'char *helploc="'$(LIBLOC)'/helpfiles";' >> libloc.c - echo 'char *cslsloc="'$(LIBLOC)'/csls";' >> libloc.c - echo 'char *temploc="/tmp";' >> libloc.c - echo 'char *separator="/";' >> libloc.c - helpfiles: mkdir helpfiles @@ -64,14 +66,17 @@ makehelp: makehelp.c $(CC) -o makehelp makehelp.c clean: - rm -f *.o libloc.c + rm -f *.o rm -Rf UCBLogo/ rm -f logo.exe rm -f *.i *.ii *.s +gitclean: + git clean -x -d -f . + ship: rm -f config.h config.cache config.log config.status - rm -f makefile makehelp logo *.o libloc.c + rm -f makefile makehelp logo *.o cd docs; $(MAKE) ship install_win: all diff --git a/mem.c b/mem.c index 5bebb05e..effc65ac 100644 --- a/mem.c +++ b/mem.c @@ -22,6 +22,7 @@ #endif #include +#include #define WANT_EVAL_REGS 1 #include "logo.h" @@ -35,6 +36,7 @@ extern NODE *stack, *numstack, *expresn, *val, *parm, *catch_tag, *arg; #endif + NODE *gcstack[GCMAX]; NODE **mark_gcstack = gcstack; @@ -127,11 +129,6 @@ BOOLEAN addseg(void) { return 0; } -#ifdef WIN32 -#pragma optimize("",off) -#endif -/* Think C tries to load ptr_val->node_type early if optimized */ - #define NILP(x) (NIL == (x)) /* GC_OPT seems to work, but valid_pointer might be needed */ @@ -161,10 +158,6 @@ BOOLEAN valid_pointer (volatile NODE *ptr_val) { return 0; } -#ifdef WIN32 -/* #pragma optimize("",on) */ -#endif - NODETYPES nodetype(NODE *nd) { if (nd == NIL) return (PNIL); return(nd->node_type); @@ -235,20 +228,9 @@ void setcdr(NODE *nd, NODE *newcdr) { check_valid_oldyoung(nd, newcdr); } -#ifdef WIN32 -#pragma optimize("",off) -#endif - - - void do_gc(BOOLEAN full) { -#if 1 - jmp_buf env; + jmp_buf env; /* get registers onto stack */ setjmp(env); -#else - register NODE *pa, *pb, *pc, *pd, *pe; /* get registers onto stack */ - register int aa, bb, cc, dd, ee; -#endif int_during_gc = 0; inside_gc++; @@ -284,10 +266,6 @@ NODE *newnode(NODETYPES type) { } else return &phony; } -#ifdef WIN32 -/* #pragma optimize("",on) */ -#endif - NODE *cons(NODE *x, NODE *y) { NODE *val = newnode(CONS); diff --git a/parse.c b/parse.c index 91f21717..ebbcd437 100644 --- a/parse.c +++ b/parse.c @@ -29,25 +29,17 @@ #undef WIN32 #endif -#ifdef WIN32 -#include -#endif - #include "logo.h" #include "globals.h" -#ifdef HAVE_TERMIO_H -#ifdef HAVE_WX -#ifndef NEW_WIN32 +#if defined(HAVE_TERMIOS_H) #include -#endif -#else +#elif defined(HAVE_TERMIO_H) #include #endif -#else -#ifdef HAVE_SGTTY_H -#include -#endif + +#ifdef HAVE_SYS_IOCTL_H +#include #endif #include @@ -78,50 +70,9 @@ int readingInstruction = 0; int rd_getc(FILE *strm) { int c; -#ifdef WIN32 - MSG msg; -#endif - -#ifndef WIN32 /* skip this section ... */ c = getc(strm); if (strm == stdin && c != EOF) update_coords(c); if (c == '\r') return rd_getc(strm); -#else /* WIN32 */ - if (strm == stdin) { - if (winPasteText && !line_avail) winDoPaste(); - if (!line_avail) { - win32_text_cursor(); - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - if (line_avail) - break; - } - } - c = read_line[read_index++]; - if (c == 17 && interactive && strm==stdin) { /* control-q */ - to_pending = 0; - err_logo(STOP_ERROR,NIL); - line_avail = 0; - free(read_line); - if (input_blocking) logo_stop(0); - return('\n'); - } - if (c == 23 && interactive && strm==stdin) { /* control-w */ - line_avail = 0; - free(read_line); - logo_pause(0); - return(rd_getc(strm)); - } - if (c == '\n') { - line_avail = 0; - free(read_line); - } - } - else /* reading from a file */ - c = getc(strm); -#endif /* WIN32 */ - #ifdef ecma return((c == EOF) ? c : ecma_clear(c)); #else @@ -191,11 +142,7 @@ NODE *reader(FILE *strm, char *prompt) { raw = 1; } charmode_off(); -#ifdef WIN32 - dribbling = 0; -#else dribbling = (dribblestream != NULL && strm == stdin); -#endif if (p_line == 0) { p_line = malloc(MAX_PHYS_LINE); if (p_line == NULL) { @@ -208,9 +155,6 @@ charmode_off(); if (strm == stdin && *prompt) { if (interactive) { rd_print_prompt(prompt); -#ifdef WIN32 - win32_update_text(); -#endif } } if (strm == stdin) { @@ -218,9 +162,6 @@ charmode_off(); erract_errtype = FATAL; } -#ifndef TIOCSTI - if (!setjmp(iblk_buf)) { -#endif c = rd_getc(strm); /* if ((c=='\b' || c=='\127') && strm==stdin && interactive) { silent_load(LogoLogo, logolib); @@ -296,9 +237,6 @@ charmode_off(); } if (c != EOF) c = rd_getc(strm); } -#ifndef TIOCSTI - } -#endif *phys_line = '\0'; input_blocking = 0; if (dribbling) @@ -367,13 +305,8 @@ NODE *parser_iterate(char **inln, char *inlimit, struct string_block *inhead, /* skip through comments and line continuations */ while (!vbar && ((semi && ch == ';') || -#ifdef WIN32 - (ch == '~' && (**inln == 012 || **inln == 015)))) { - while (ch == '~' && (**inln == 012 || **inln == 015)) { -#else (ch == '~' && **inln == '\n'))) { while (ch == '~' && **inln == '\n') { -#endif if (++(*inln) >= inlimit) *inln = &terminate; ch = **inln; if (windex == 0) wptr = *inln; @@ -390,22 +323,14 @@ NODE *parser_iterate(char **inln, char *inlimit, struct string_block *inhead, } if (semi && ch == ';') { -#ifdef WIN32 - if (**inln != 012 && **inln != 015) -#else if (**inln != '\n') -#endif do { ch = **inln; if (windex == 0) wptr = *inln; else broken = TRUE; if (++(*inln) >= inlimit) *inln = &terminate; } -#ifdef WIN32 - while (ch != '\0' && ch != '~' && **inln != 012 && **inln != 015); -#else /* !Win32 */ while (ch != '\0' && ch != '~' && **inln != '\n'); -#endif if (ch != '\0' && ch != '~') ch = '\n'; } } diff --git a/term.c b/term.c index fbd3dc03..aedcf726 100644 --- a/term.c +++ b/term.c @@ -29,16 +29,14 @@ #include #endif -#ifdef HAVE_TERMIO_H -#ifdef HAVE_WX +#if defined(HAVE_TERMIOS_H) #include -#else +#elif defined(HAVE_TERMIO_H) #include #endif -#else -#ifdef HAVE_SGTTY_H -#include -#endif + +#ifdef HAVE_SYS_IOCTL_H +#include #endif #undef TRUE @@ -46,9 +44,6 @@ #ifdef HAVE_TERMCAP_H #include -#ifdef HAVE_SGTTY_H -#include -#endif #else #ifdef HAVE_TERMLIB_H #include @@ -77,13 +72,7 @@ char cm_arr[40]; char so_arr[40]; char se_arr[40]; -#ifdef HAVE_TERMIO_H struct termio tty_cooked, tty_cbreak; -#else -#ifdef HAVE_SGTTY_H -struct sgttyb tty_cooked, tty_cbreak; -#endif -#endif int interactive, tty_charmode; @@ -97,7 +86,6 @@ int termcap_putter(int ch) { return 0; } -#ifdef unix void termcap_getter(char *cap, char *buf) { char temp[40]; char *str; @@ -108,34 +96,20 @@ void termcap_getter(char *cap, char *buf) { /* if (str == NULL) str = temp; */ tputs(str,1,termcap_putter); } -#endif void term_init(void) { -#ifdef unix char *emacs; /* emacs change */ int term_sg; int tgetent_result; -#endif -#ifdef WIN32 - interactive = 1; -#else interactive = isatty(0); -#endif if (interactive) { -#ifdef HAVE_TERMIO_H ioctl(0,TCGETA,(char *)(&tty_cooked)); tty_cbreak = tty_cooked; tty_cbreak.c_cc[VMIN] = '\01'; tty_cbreak.c_cc[VTIME] = '\0'; tty_cbreak.c_lflag &= ~(ECHO|ICANON); -#else - ioctl(0,TIOCGETP,(char *)(&tty_cooked)); - tty_cbreak = tty_cooked; - tty_cbreak.sg_flags |= CBREAK; - tty_cbreak.sg_flags &= ~ECHO; -#endif } tty_charmode = 0; @@ -182,46 +156,24 @@ void term_init(void) { } void charmode_on() { -#ifdef unix if ((readstream == stdin) && interactive && !tty_charmode) { -#ifdef HAVE_TERMIO_H ioctl(0,TCSETA,(char *)(&tty_cbreak)); -#else /* !HAVE_TERMIO_H */ - ioctl(0,TIOCSETP,(char *)(&tty_cbreak)); -#endif /* HAVE_TERMIO_H */ tty_charmode++; } -#endif /* unix */ -#ifdef WIN32 - win32_charmode_on(); -#endif } void charmode_off() { -#ifdef unix if (tty_charmode) { -#ifdef HAVE_TERMIO_H ioctl(0,TCSETA,(char *)(&tty_cooked)); -#else /* !HAVE_TERMIO_H */ - ioctl(0,TIOCSETP,(char *)(&tty_cooked)); -#endif /* HAVE_TERMIO_H */ tty_charmode = 0; } -#endif /* unix */ -#ifdef WIN32 - win32_charmode_off(); -#endif } NODE *lcleartext(NODE *args) { printf("%s", cl_arr); printf("%s", tgoto(cm_arr, x_margin, y_margin)); -#ifdef WIN32 - win32_update_text(); -#else fflush(stdout); /* do it now! */ -#endif fix_turtle_shownness(); x_coord = x_margin; @@ -240,9 +192,6 @@ NODE *lcursor(NODE *args) { NODE *lsetcursor(NODE *args) { fix_turtle_shownness(); -#ifdef WIN32 - return (win32_lsetcursor(args)); -#else /* !win32 */ NODE *arg; arg = pos_int_vector_arg(args); @@ -263,7 +212,6 @@ NODE *lsetcursor(NODE *args) { fflush(stdout); } return(UNBOUND); -#endif /* !win32 (for non-windows version of this code) */ } NODE *lsetmargins(NODE *args) { diff --git a/win32trm.c b/win32trm.c deleted file mode 100644 index e27e7063..00000000 --- a/win32trm.c +++ /dev/null @@ -1,1374 +0,0 @@ -/* -*-C-*- - * win32trm.c -- Module to provide Win32 API compliant graphics routines - * - * Copyright (C) 1996 by the Regents of the University of California - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include - -#include "logo.h" -#include "globals.h" -#include "win32trm.h" -#include "ucbwlogo/resource.h" - -// #define WIN32_S - -LRESULT CALLBACK ParentWindowFunc(HWND, UINT, WPARAM, LPARAM); - -char szWinName[] = "UCBLogo"; -char szGraphWinName[] = "UCBLogoGraph"; -char szConWinName[] = "UCBLogoConsole"; - -char *LogoPlatformName="Windows"; - -pen_info turtlePen; - -HBRUSH hbrush, textbrush; - -HBITMAP hbitG, hbitmG, hbitC, hbitmC; -RECT allRect; - -HDC GraphDC, memGraphDC, ConDC, memConDC; -HWND hGraphWnd, hConWnd, hMainWnd; - -/* color and palette related information */ -static COLORREF palette[266]; -FIXNUM back_ground, pen_color, old_pen_color; - -int maxX, maxY, greeted = 0; -int pre_turtle_pen_mode; -long Xsofar, Ysofar; -int w_button = 0; -FIXNUM mouse_x = 0, mouse_y = 0; - -BOOLEAN in_erase_mode, update_pos, seen_once = FALSE; - -int in_graphics_mode, in_splitscreen; - -static char **win32_lines; // for recording what should appear in the text win -static char input_lines[2][200]; - -char *read_line, buffered_char; -int cur_line = 0, cur_index = 0, read_index, hpos = 0, margin, cur_len; -int char_mode = 0, input_line = 0, input_index = 0; - -int line_avail = FALSE, char_avail = FALSE; -char *winPasteText = NULL, *winPastePtr = NULL; -char *myScreen = NULL; -int maxXChar, maxYChar; - -/* Default font behavior set here: OEM_FIXED_FONT, ANSI_FIXED_FONT, or default */ -BOOLEAN oemfont = FALSE; -BOOLEAN ansifont = TRUE; - -#ifdef WIN32_DEBUG -void WinDebug(char *s) { - ndprintf("%t", s); -} -#endif - -int win32_screen_right(void) { - RECT r; - - GetClientRect(hMainWnd, &r); - return (int) r.right; -} - -int win32_screen_bottom(void) { - RECT r; - - GetClientRect(hMainWnd, &r); - return (int) r.bottom; -} - -void moveto(int x, int y) { - /* no invalidation of the rectangle, etc needs to be done. */ - turtlePen.h = x; - turtlePen.v = y; - MoveCursor(x, y); -} - -void lineto(int x, int y) { - turtlePen.h = x; - turtlePen.v = y; - LineTo(memGraphDC, x, y); - LineTo(GraphDC, x, y); - /* Good old Windows does us the favor of leaving out - the endpoint, so we have to beat it up */ - LineTo(memGraphDC, x, y+1); - LineTo(GraphDC, x, y+1); - MoveCursor(x, y); -} - -void win32_go_away(void) { - int i; - - if (read_line != NULL) - free(read_line); - for (i = 0; i < NUM_LINES; i++) - if (win32_lines[i] != NULL) - free(win32_lines[i]); - if (win32_lines != NULL) - free(win32_lines); - DeleteDC(memConDC); - DeleteDC(memGraphDC); - DeleteDC(GraphDC); - DeleteDC(ConDC); - DeleteObject(turtlePen.hpen); - DeleteObject(hbrush); - DeleteObject(textbrush); - DeleteObject(hbitC); - DeleteObject(hbitmC); - DeleteObject(hbitG); - DeleteObject(hbitmG); - exit(0); -} - -void win32_update_text(void) { - RECT r; - - GetClientRect(hConWnd, &r); - BitBlt(ConDC, 0, 0, r.right, r.bottom, memConDC, 0, 0, SRCCOPY); -} - -void win32_repaint_screen(void) { - PostMessage(hMainWnd, WM_SETFOCUS, 0, 0); -} - -void win32_advance_line(void) { - TEXTMETRIC tm; - RECT r, inv, foo; - int xpos, ypos; - - GetClientRect(hConWnd, &r); - GetTextMetrics(memConDC, &tm); - - xpos = (tm.tmAveCharWidth * x_coord); - ypos = ((tm.tmHeight + tm.tmExternalLeading) * y_coord); - - if ((ypos + 2 * (tm.tmHeight + tm.tmExternalLeading)) >= r.bottom) { - memmove(myScreen, myScreen+maxXChar, maxXChar*(maxYChar-1)); - ScrollDC(ConDC, 0, - (tm.tmHeight + tm.tmExternalLeading), - &r, &r, NULL, &inv); - FillRect(ConDC, &inv, textbrush); - foo.left = 0; - foo.right = Xsofar; - foo.top = 0; - foo.bottom = Ysofar; - ScrollDC(memConDC, 0, - (tm.tmHeight + tm.tmExternalLeading), - &foo, &foo, NULL, &inv); - FillRect(memConDC, &inv, textbrush); - } -} - -void draw_string(char *str) { - TEXTMETRIC tm; - int x, y; - - GetTextMetrics(memGraphDC, &tm); - x = turtlePen.h; - y = turtlePen.v; - TextOut(memGraphDC, x, y - tm.tmHeight, str, strlen(str)); - TextOut(GraphDC, x, y - tm.tmHeight, str, strlen(str)); - /* restore position */ - moveto(x, y); -} - -char *eight_dot_three_helper(char *in) { - static char out[20]; - char *filename, *extension; - - filename = strtok(in, "."); - extension = strtok(NULL, "."); - - if (extension) - sprintf(out, "%.8s.%.3s", filename, extension); - else - sprintf(out, "%.8s", filename); - return out; -} - -char *eight_dot_three(char *in) { - static char out[100]; - char *last, *last_sep, *fear; - int index; - - if (last_sep = strrchr(in, '\\')) { - index = last_sep - in; - index++; - strncpy(out, in, index); - out[index] = '\0'; - last = (char *)malloc((strlen(in) - index + 3) * sizeof(char)); - strncpy(last, &in[index], strlen(in) - index); - last[strlen(in) - index] = '\0'; - } else if (last_sep = strrchr(in, ':')) { - index = last_sep - in; - index++; - strncpy(out, in, index); - out[index] = '\0'; - last = (char *)malloc((strlen(in) - index + 3) * sizeof(char)); - strncpy(last, &in[index], strlen(in) - index); - last[strlen(in) - index] = '\0'; - } - for (fear = last; *fear != '\0'; fear++) - if (*fear == '?') *fear = 'Q'; - fear = eight_dot_three_helper(last); - strcat(out, fear); - free(last); - return out; -} - -void MoveCursor(int newx, int newy) { - MoveToEx(memGraphDC, newx, newy, NULL); - MoveToEx(GraphDC, newx, newy, NULL); -} - -void win32_erase_screen(void) { - PatBlt(memGraphDC, 0, 0, maxX, maxY, PATCOPY); - PatBlt(GraphDC, 0, 0, maxX, maxY, PATCOPY); -} - -void win32_set_bg(FIXNUM c) { - /* - * set global variables that denote the background color, create a new - * brush with the desired color, repaint the memory context, wait for - * WM_PAINT, and redraw the old display (using the records...) - */ - back_ground = c; - hbrush = CreateSolidBrush(palette[back_ground+2]); - SelectObject(memGraphDC, hbrush); - DeleteObject(SelectObject(GraphDC, hbrush)); - PatBlt(memGraphDC, 0, 0, maxX, maxY, PATCOPY); - PatBlt(GraphDC, 0, 0, maxX, maxY, PATCOPY); - SetBkColor(memGraphDC, palette[back_ground+2]); - SetBkColor(GraphDC, palette[back_ground+2]); - redraw_graphics(); -} - -void win32_clear_text(void) { - // RECT r; - /* - * Draw over the entire client area, so that in split screen mode, for - * example, there are no ghosts, when the user returns to textscreen mode. - */ - - // GetClientRect(hConWnd, &r); - memset(myScreen, ' ',maxXChar*maxYChar); - FillRect(ConDC, &allRect, textbrush); - FillRect(memConDC, &allRect, textbrush); -} - -LRESULT CALLBACK GraphWindowFunc(HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam) { - HFONT hfont; - PAINTSTRUCT ps; - - switch (message) { - case WM_CREATE: - /* - * Now, create a copy of the entire screen in memory to act as a virtual - * window to record turtle motions so they can be repainted in a - * WM_PAINT message. - */ - GraphDC = GetDC(hwnd); - memGraphDC = CreateCompatibleDC(GraphDC); - maxX = GetSystemMetrics(SM_CXSCREEN); - maxY = GetSystemMetrics(SM_CYSCREEN); - hbitmG = CreateCompatibleBitmap(GraphDC, maxX, maxY); - SelectObject(memGraphDC, hbitmG); - hbitG = CreateCompatibleBitmap(GraphDC, maxX, maxY); - SelectObject(GraphDC, hbitG); - if (oemfont) { - hfont = GetStockObject(OEM_FIXED_FONT); - SelectObject(memGraphDC, hfont); - SelectObject(GraphDC, hfont); - } - if (ansifont) { - hfont = GetStockObject(ANSI_FIXED_FONT); - SelectObject(memGraphDC, hfont); - SelectObject(GraphDC, hfont); - } - /* - * first-time initialization of the brush for the background requires - * setting the back_ground, and selecting the right color. while - * there may be stock objects that contain the right color for the - * initial pen/brush, subsequent changes might try to delete these - * "stock" pens/brushes, and that would be "Bad". - */ - back_ground = 0; - hbrush = CreateSolidBrush(palette[back_ground+2]); - SetBkColor(memGraphDC, palette[back_ground+2]); - SetBkColor(GraphDC, palette[back_ground+2]); - SelectObject(memGraphDC, hbrush); - SelectObject(GraphDC, hbrush); - - /* - * first-time initialization of the pen structure requires setting up - * all of the fields in the data first, then creating a new pen object - */ - turtlePen.h = 0; /* ?? */ - turtlePen.v = 0; /* ?? */ - turtlePen.vis = 0; - turtlePen.mode = WIN_PEN_DOWN; - turtlePen.width = 1; /* default */ - turtlePen.color = pen_color = old_pen_color = 7; - /* turtlePen.pattern = ... ? */ - turtlePen.hpen = CreatePen(PS_SOLID, turtlePen.width, - palette[2+turtlePen.color]); - SetTextColor(memGraphDC, palette[2+turtlePen.color]); - SetTextColor(GraphDC, palette[2+turtlePen.color]); - SelectObject(memGraphDC, turtlePen.hpen); - SelectObject(GraphDC, turtlePen.hpen); - PatBlt(memGraphDC, 0, 0, maxX, maxY, PATCOPY); - PatBlt(GraphDC, 0, 0, maxX, maxY, PATCOPY); - break; - case WM_LBUTTONDOWN: - w_button = 1; - goto abutton; - case WM_RBUTTONDOWN: - w_button = 2; - goto abutton; - case WM_MBUTTONDOWN: - w_button = 3; -abutton: - SetCapture(hwnd); - case WM_MOUSEMOVE: - mouse_x = (LOWORD(lParam))-(screen_width/2); - mouse_y = (screen_height/2)-(HIWORD(lParam)); - break; - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MBUTTONUP: - w_button = 0; - ReleaseCapture(); - break; - case WM_USER: - InvalidateRect(hGraphWnd, NULL, 1); - case WM_PAINT: - BeginPaint(hGraphWnd, &ps); - BitBlt(ps.hdc, 0, 0, maxX, maxY, memGraphDC, 0, 0, SRCCOPY); - EndPaint(hGraphWnd, &ps); - break; - case WM_DESTROY: /* end program */ - PostQuitMessage(0); - break; - default: - return DefWindowProc(hwnd, message, wParam, lParam); - } - return 0; -} - -void win32_text_cursor(void) { - print_char(stdout, '_'); - update_coords('\b'); -} - -void DrawBoxOutline(POINT ptBeg, POINT ptEnd) { - SetROP2(ConDC, R2_NOT); - SelectObject(ConDC, GetStockObject(NULL_BRUSH)); - Rectangle(ConDC, ptBeg.x, ptBeg.y, ptEnd.x, ptEnd.y); -} - -LRESULT CALLBACK ConsoleWindowFunc(HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam) { - HFONT hfont; - PAINTSTRUCT ps; - RECT rect; - TEXTMETRIC tm; - HGLOBAL hClipMemory, hCopyText; - PSTR pClipMemory, copyText; - static int fBlocking=FALSE, haveBlock=FALSE; - static POINT ptBeg, ptEnd; - static int chBegX, chBegY, chEndX, chEndY; - char *copyPtr; - int i,j; - - switch (message) { - case WM_CREATE: - ConDC = GetDC(hwnd); - memConDC = CreateCompatibleDC(ConDC); - allRect.left = allRect.top = 0; - allRect.right = maxX = GetSystemMetrics(SM_CXSCREEN); - allRect.bottom = maxY = GetSystemMetrics(SM_CYSCREEN); - hbitmC = CreateCompatibleBitmap(ConDC, maxX, maxY); - SelectObject(memConDC, hbitmC); - hbitC = CreateCompatibleBitmap(ConDC, maxX, maxY); - SelectObject(ConDC, hbitC); - if (oemfont) { - hfont = GetStockObject(OEM_FIXED_FONT); - SelectObject(memConDC, hfont); - SelectObject(ConDC, hfont); - } - if (ansifont) { - hfont = GetStockObject(ANSI_FIXED_FONT); - SelectObject(memConDC, hfont); - SelectObject(ConDC, hfont); - } - textbrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); - SelectObject(memConDC, textbrush); - SelectObject(ConDC, textbrush); - FillRect(memConDC, &allRect, textbrush); - GetClientRect(hConWnd, &rect); - GetTextMetrics(ConDC, &tm); - maxXChar = maxX / tm.tmAveCharWidth; - maxYChar = maxY / (tm.tmHeight + tm.tmExternalLeading); - myScreen = (char *)malloc(maxXChar * maxYChar); - memset(myScreen, ' ',maxXChar*maxYChar); - ibm_plain_mode(); - break; - case WM_LBUTTONDOWN: - if (haveBlock) DrawBoxOutline(ptBeg, ptEnd); - GetTextMetrics(memConDC, &tm); - ptEnd.x = LOWORD(lParam); - ptEnd.y = HIWORD(lParam); - ptEnd.x = (ptEnd.x/tm.tmAveCharWidth) * tm.tmAveCharWidth; - ptEnd.y = (ptEnd.y/(tm.tmHeight + tm.tmExternalLeading)) - * (tm.tmHeight + tm.tmExternalLeading); - ptBeg.x = ptEnd.x; - ptBeg.y = ptEnd.y; - DrawBoxOutline(ptBeg, ptEnd); - SetCapture(hwnd); - fBlocking = TRUE; - haveBlock = FALSE; - return 0; - case WM_MOUSEMOVE: - GetTextMetrics(memConDC, &tm); - if (fBlocking) { - DrawBoxOutline(ptBeg, ptEnd); - ptEnd.x = LOWORD(lParam); - ptEnd.y = HIWORD(lParam); - ptEnd.x = (ptEnd.x/tm.tmAveCharWidth) * tm.tmAveCharWidth; - ptEnd.y = (ptEnd.y/(tm.tmHeight + tm.tmExternalLeading)) - * (tm.tmHeight + tm.tmExternalLeading); - DrawBoxOutline(ptBeg, ptEnd); - } - return 0; - case WM_LBUTTONUP: - if (fBlocking) { - ReleaseCapture(); - fBlocking = FALSE; - haveBlock=TRUE; - GetClientRect(hConWnd, &rect); - if (ptEnd.x >= 0 && ptEnd.y >= 0 && ptEnd.x < rect.right && - ptEnd.y < rect.bottom) { - GetTextMetrics(memConDC, &tm); - chBegX = ptBeg.x/tm.tmAveCharWidth; - chBegY = ptBeg.y/(tm.tmHeight + tm.tmExternalLeading); - chEndX = ptEnd.x/tm.tmAveCharWidth; - chEndY = ptEnd.y/(tm.tmHeight + tm.tmExternalLeading); - } else { - DrawBoxOutline(ptBeg, ptEnd); - haveBlock = FALSE; - } - } - return 0; - case WM_CHAR: - if (haveBlock) DrawBoxOutline(ptBeg, ptEnd); - if (char_mode) { - buffered_char = (char)wParam; - char_avail++; - haveBlock = FALSE; - return 0; - } - print_space(stdout); // flush cursor - update_coords('\b'); - if ((char) wParam == '\b') { - if (cur_index > 0) { - update_coords('\b'); - print_space(stdout); - update_coords('\b'); - win32_text_cursor(); - cur_index--; - } else { - MessageBeep(0); - haveBlock = FALSE; - win32_lines[cur_line][cur_index++] = (char) wParam; - print_char(stdout, (char) wParam); - win32_text_cursor(); - } - } else if ((char) wParam == '\r') { // line ready, let's go! - print_char(stdout, '\n'); - haveBlock = FALSE; - win32_lines[cur_line][cur_index++] = '\n'; // reader code expects \n - win32_lines[cur_line][cur_index] = '\0'; - cur_len = cur_index; - read_line = (char *)malloc((strlen(win32_lines[cur_line]) + 1) * - sizeof(char)); - strncpy(read_line, win32_lines[cur_line], cur_index + 1); - line_avail = 1; - read_index = 0; - if (++cur_line >= NUM_LINES) - cur_line %= NUM_LINES; // wrap around - cur_index = 0; - return 0; - } else if ((char)wParam == 17 || (char)wParam == 23) { - haveBlock = FALSE; - print_char(stdout, '\n'); - read_line = (char *)malloc(sizeof(char)); - *read_line = (char)wParam; - line_avail = 1; - read_index = 0; - cur_index = 0; - return 0; - } else if ((char)wParam == 3 && haveBlock) { /* ^C for copy */ - int temp; - haveBlock = FALSE; - if (chEndX < chBegX) { - temp = chEndX; - chEndX = chBegX; - chBegX = temp; - } - if (chEndY < chBegY) { - temp = chEndY; - chEndY = chBegY; - chBegY = temp; - } - hCopyText = GlobalAlloc(GHND, - (chEndY-chBegY)*(2+chEndX-chBegX)+1); - copyText = GlobalLock(hCopyText); - copyPtr = copyText; - for (i=chBegY; i= NUM_LINES) - cur_line %= NUM_LINES; // wrap around - cur_index = 0; - return; - } - if (ch != 3 && ch != 22 && ch != '\n') { - win32_lines[cur_line][cur_index++] = ch; - print_char(stdout, ch); - } - ch = *winPastePtr++; - } - free(winPasteText); - winPasteText = NULL; -} - -NODE *win32_get_node_pen_pattern(void) { - return cons(make_intnode(-1), NIL); -} - -NODE *maximize(NODE *args) { - int big=torf_arg(args); - ShowWindow(hMainWnd, (big ? SW_MAXIMIZE : SW_RESTORE)); - UpdateWindow(hMainWnd); - return UNBOUND; -} - -void logofill(void) { - COLORREF col; - - hbrush = CreateSolidBrush(palette[2+pen_color]); - SelectObject(memGraphDC, hbrush); - DeleteObject(SelectObject(GraphDC, hbrush)); - col = GetPixel(memGraphDC, g_round(screen_x_coord), g_round(screen_y_coord)); - (void)ExtFloodFill(memGraphDC, g_round(screen_x_coord), - g_round(screen_y_coord), col, FLOODFILLSURFACE); - (void)ExtFloodFill(GraphDC, g_round(screen_x_coord), - g_round(screen_y_coord), col, FLOODFILLSURFACE); - hbrush = CreateSolidBrush(palette[2+back_ground]); - SelectObject(memGraphDC, hbrush); - DeleteObject(SelectObject(GraphDC, hbrush)); -} - -void get_pen_pattern(void) { -} - -void set_pen_pattern(void) { -} - -void get_palette(int slot, unsigned int *r, unsigned int *g, unsigned int *b) { - if (slot > 263 || (slot >= 0 && slot < 8) || slot < -2) // 256 rgb values - return; - slot+=2; - *b = ((palette[slot % 264] & 0x00ff0000) >> 16) * 256; - *g = ((palette[slot % 264] & 0x0000ff00) >> 8) * 256; - *r = (palette[slot % 264] & 0x000000ff) * 256; -} - -void set_palette(int slot, unsigned int r, unsigned int g, unsigned int b) { - if (slot > 263 || (slot >= 0 && slot < 8) || slot < -2) // 256 rgb values - return; - slot+=2; - palette[slot] = RGB(r/256, g/256, b/256); -} - -void save_pen(pen_info *p) { - POINT pt; - - p->vis = pen_vis; - p->color = pen_color; - GetCurrentPositionEx(memGraphDC, &pt); - p->h = (int) pt.x; - p->v = (int) pt.y; - p->width = turtlePen.width; - p->mode = turtlePen.mode; -} - -void restore_pen(pen_info *p) { - pen_vis = p->vis; - MoveCursor(p->h, p->v); - turtlePen.mode = p->mode; - win32_set_pen_mode(turtlePen.mode); - turtlePen.width = p->width; - pen_color = p->color; - turtlePen.hpen = CreatePen(PS_SOLID, turtlePen.width, - (in_erase_mode ? palette[2+back_ground] - : palette[2+pen_color])); - SelectObject(memGraphDC, turtlePen.hpen); - DeleteObject(SelectObject(GraphDC, turtlePen.hpen)); -} - -void set_list_pen_pattern(void) { -} - -void label(char *str) { - draw_string(str); -} - -void plain_xor_pen(void) { - win32_set_pen_mode(WIN_PEN_REVERSE); -} - -BOOLEAN check_ibm_stop(void) { - MSG msg; - SHORT s; - static int count; - - if ((s = GetAsyncKeyState(VK_CONTROL)) < 0) { - if ((s = GetAsyncKeyState(65 + ('q' - 'a')) < 0)) { - err_logo(STOP_ERROR,NIL); - return (1); - } - if ((s = GetAsyncKeyState(65 + ('w' - 'a')) < 0)) { - // control w - to_pending = 0; - lpause(NIL); - } - } - count++; - count %= 300; // empirical value - - if (!count) { - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) - ; - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } - return FALSE; -} - -void win32_con_full_screen(void) { - RECT r; - PAINTSTRUCT ps; - - if (in_graphics_mode && !in_splitscreen) - return; - in_graphics_mode = 1; - in_splitscreen = 0; - - GetClientRect(hMainWnd, &r); - /* position coordinates are relative to the parent's frame. */ - MoveWindow(hGraphWnd, 0, 0, r.right, r.bottom, TRUE); - ShowWindow(hConWnd, SW_HIDE); - ShowWindow(hGraphWnd, SW_SHOWNORMAL); - BeginPaint(hGraphWnd, &ps); - BitBlt(ps.hdc, 0, 0, maxX, maxY, memGraphDC, 0, 0, SRCCOPY); - EndPaint(hGraphWnd, &ps); - redraw_graphics(); -} - -void win32_prepare_draw(void) { - if (in_graphics_mode) return; - win32_con_split_screen(); -} - -long upscroll_text(int limit) { - TEXTMETRIC tm; - RECT r, inv; - int y_new, offset, old, rbot; - - GetClientRect(hMainWnd, &r); - GetTextMetrics(memConDC, &tm); - y_new = r.bottom; - y_new /= (tm.tmHeight + tm.tmExternalLeading); - rbot = y_new * (tm.tmHeight + tm.tmExternalLeading); - y_new--; - if (limit > 0 && limit < y_new) { - y_new = limit; - rbot = r.bottom = (limit+1) * (tm.tmHeight + tm.tmExternalLeading); - } - offset = y_coord - y_new; - if (offset > 0) { - old = (y_coord + 1) * (tm.tmHeight + tm.tmExternalLeading); - BitBlt(ConDC, 0, 0, maxX, maxY, memConDC, 0, old-rbot, SRCCOPY); - inv.left = 0; - inv.right = allRect.right; - inv.top = rbot - 1; - inv.bottom = allRect.bottom; - BitBlt(memConDC, 0, 0, maxX, maxY, ConDC, 0, 0, SRCCOPY); - FillRect(memConDC, &inv, textbrush); - y_coord = y_new; - } - return r.bottom; -} - -void reshow_text(void) { - TEXTMETRIC tm; - RECT r, foo; - - ShowWindow(hConWnd, SW_SHOW); - GetClientRect(hConWnd, &r); - GetTextMetrics(memConDC, &tm); - FillRect(ConDC, &r, textbrush); - if (r.right > Xsofar) { - foo.left = Xsofar; - foo.right = r.right; - foo.top = 0; - foo.bottom = allRect.bottom; - FillRect(memConDC, &foo, textbrush); - Xsofar = r.right; - } - if (r.bottom > Ysofar) { - foo.left = 0; - foo.right = r.right; - foo.top = Ysofar; - foo.bottom = r.bottom; - FillRect(memConDC, &foo, textbrush); - Ysofar = r.bottom; - } - BitBlt(ConDC, 0, 0, r.right, r.bottom, memConDC, 0, 0, SRCCOPY); - ValidateRect(hConWnd, &r); - - x_max = r.right; - x_max /= tm.tmAveCharWidth; - x_max--; - - y_max = r.bottom; - y_max /= (tm.tmHeight + tm.tmExternalLeading); - y_max--; -} - -void win32_con_split_screen(void) { - RECT r; - PAINTSTRUCT ps; - long vert; - - if (in_graphics_mode && in_splitscreen) - return; - in_graphics_mode = in_splitscreen = 1; - - ShowWindow(hConWnd, SW_SHOW); - vert = upscroll_text(3); - GetClientRect(hMainWnd, &r); - MoveWindow(hConWnd, 0, r.bottom - vert - 6, r.right, vert + 6, FALSE); - MoveWindow(hGraphWnd, 0, 0, r.right, r.bottom - vert - 8, TRUE); - ShowWindow(hGraphWnd, SW_HIDE); - BeginPaint(hGraphWnd, &ps); - BitBlt(ps.hdc, 0, 0, maxX, maxY, memGraphDC, 0, 0, SRCCOPY); - EndPaint(hGraphWnd, &ps); - reshow_text(); - redraw_graphics(); - ShowWindow(hGraphWnd, SW_SHOW); - if (!seen_once) { - seen_once = TRUE; - lclearscreen(NIL); - } -} - -void win32_con_text_screen(void) { - RECT r; - - if (!in_graphics_mode) - return; - in_graphics_mode = in_splitscreen = 0; - - (void)upscroll_text(0); - GetClientRect(hMainWnd, &r); - MoveWindow(hConWnd, 0, 0, r.right, r.bottom, FALSE); - ShowWindow(hGraphWnd, SW_HIDE); - reshow_text(); -} - -void win32_turtle_prep(void) { - if (in_erase_mode) { - /* current pen color != "real" pen color */ - turtlePen.hpen = CreatePen(PS_SOLID, turtlePen.width, palette[2+pen_color]); - SelectObject(memGraphDC, turtlePen.hpen); - DeleteObject(SelectObject(GraphDC, turtlePen.hpen)); - } else { - SelectObject(memGraphDC, turtlePen.hpen); - SelectObject(GraphDC, turtlePen.hpen); - } - update_pos = FALSE; - pre_turtle_pen_mode = SetROP2(memGraphDC, R2_XORPEN); - (void)SetROP2(GraphDC, R2_XORPEN); -} - -void win32_turtle_end(void) { - if (in_erase_mode) { - /* - * current pen color should now be set to background color to resume - * "erase mode" - */ - turtlePen.hpen = CreatePen(PS_SOLID, turtlePen.width, palette[2+back_ground]); - SelectObject(memGraphDC, turtlePen.hpen); - DeleteObject(SelectObject(GraphDC, turtlePen.hpen)); - } else { - SelectObject(memGraphDC, turtlePen.hpen); - SelectObject(GraphDC, turtlePen.hpen); - } - update_pos = TRUE; - SetROP2(memGraphDC, pre_turtle_pen_mode); - SetROP2(GraphDC, pre_turtle_pen_mode); -} - -void win32_init_palette(void) { - palette[2] = RGB(0, 0, 0); /* black */ - palette[3] = RGB(0, 0, 255); /* blue */ - palette[4] = RGB(0, 255, 0); /* green */ - palette[5] = RGB(0, 255, 255); /* cyan */ - palette[6] = RGB(255, 0, 0); /* red */ - palette[7] = RGB(255, 0, 255); /* magenta */ - palette[8] = RGB(255, 255, 0); /* yellow */ - palette[9] = RGB(255, 255, 255); /* white */ - palette[10] = RGB(155, 96, 59); /* brown */ - palette[11] = RGB(197, 136, 18); /* tan */ - palette[12] = RGB(100, 162, 64); /* forest */ - palette[13] = RGB(120, 187, 187); /* aqua */ - palette[14] = RGB(255, 149, 119); /* salmon */ - palette[15] = RGB(144, 113, 208); /* purple */ - palette[16] = RGB(255, 163, 0); /* orange */ - palette[17] = RGB(183, 183, 183); /* gray */ - /* rest are user defined */ -} - -void win32_set_pen_color(int c) { - draw_turtle(); - turtlePen.color = pen_color = c; - if (!in_erase_mode) { - turtlePen.hpen = CreatePen(PS_SOLID, turtlePen.width, - palette[2+turtlePen.color]); - SelectObject(memGraphDC, turtlePen.hpen); - DeleteObject(SelectObject(GraphDC, turtlePen.hpen)); - } - SetTextColor(memGraphDC, palette[2+pen_color]); - SetTextColor(GraphDC, palette[2+pen_color]); - draw_turtle(); -} - -int win32_set_pen_width(int w) { - int old; - - old = turtlePen.width; - turtlePen.width = w; - turtlePen.hpen = CreatePen(PS_SOLID, turtlePen.width, - (in_erase_mode ? palette[2+back_ground] - : palette[2+turtlePen.color])); - SelectObject(memGraphDC, turtlePen.hpen); - DeleteObject(SelectObject(GraphDC, turtlePen.hpen)); - return old; -} - -NODE *win32_lsetcursor(NODE *args) { - NODE *arg; - TEXTMETRIC tm; - int xpos, ypos; - - GetTextMetrics(memConDC, &tm); - - arg = pos_int_vector_arg(args); - if (NOT_THROWING) { - x_coord = x_margin + getint(car(arg)); - y_coord = y_margin + getint(cadr(arg)); - while ((x_coord >= x_max || y_coord >= y_max) && NOT_THROWING) { - setcar(args, err_logo(BAD_DATA, arg)); - if (NOT_THROWING) { - arg = pos_int_vector_arg(args); - x_coord = x_margin + getint(car(arg)); - y_coord = y_margin + getint(cadr(arg)); - } - } - } - - xpos = tm.tmAveCharWidth * x_coord; - ypos = (tm.tmHeight + tm.tmExternalLeading) * y_coord; - - if (NOT_THROWING) { - MoveToEx(memConDC, xpos, ypos, NULL); - MoveToEx(ConDC, xpos, ypos, NULL); - } - return(UNBOUND); -} - -void win32_pen_erase(void) { - win32_set_pen_mode(WIN_PEN_ERASE); -} - -void win32_pen_down(void) { - win32_set_pen_mode(WIN_PEN_DOWN); -} - -void win32_pen_reverse(void) { - win32_set_pen_mode(WIN_PEN_REVERSE); -} - -void win32_set_pen_mode(int newmode) { - int rop2_mode, newpc; - - turtlePen.mode = newmode; - - if (newmode == WIN_PEN_ERASE) - in_erase_mode = TRUE; - else - in_erase_mode = FALSE; - - if (newmode == WIN_PEN_REVERSE) - rop2_mode = R2_XORPEN; - else - rop2_mode = R2_COPYPEN; - - SetROP2(memGraphDC, rop2_mode); - SetROP2(GraphDC, rop2_mode); - - if (newmode == WIN_PEN_ERASE) - newpc = back_ground; - else - newpc = pen_color; - turtlePen.hpen = CreatePen(PS_SOLID, turtlePen.width, palette[2+newpc]); - SelectObject(memGraphDC, turtlePen.hpen); - DeleteObject(SelectObject(GraphDC, turtlePen.hpen)); -} - -LRESULT CALLBACK ParentWindowFunc(HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam) { - RECT r; - - switch (message) { - case WM_CHAR: - SendMessage(hConWnd, WM_CHAR, wParam, lParam); - break; - case WM_SIZE: - case WM_EXITSIZEMOVE: - if (wParam != SIZE_MINIMIZED) { - if (!in_graphics_mode) { // Text screen mode - in_graphics_mode = 1; - win32_con_text_screen(); - } else if (in_splitscreen) { - in_splitscreen = 0; - win32_con_split_screen(); - } else { - in_graphics_mode = 0; - win32_con_full_screen(); - } - } - case WM_MOVE: - case WM_SETFOCUS: - case WM_EXITMENULOOP: - if (!in_graphics_mode || in_splitscreen) - SendMessage(hConWnd, WM_USER, wParam, lParam); - if (in_graphics_mode) - SendMessage(hGraphWnd, WM_USER, wParam, lParam); - win32_update_text(); - break; - case WM_PAINT: - /* - * The parent window really has nothing to draw. Therefore, all that - * the parent window's paint function does is dispatch the appropriate - * message to the child window. - */ - if (!in_graphics_mode || in_splitscreen) - SendMessage(hConWnd, WM_PAINT, wParam, lParam); - if (in_graphics_mode) - SendMessage(hGraphWnd, WM_PAINT, wParam, lParam); - GetClientRect(hwnd, &r); - ValidateRect(hwnd, &r); - break; - case WM_CREATE: - hConWnd = CreateWindow(szConWinName, NULL, - WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER, - 0, 0, 0, 0, - hwnd, (HMENU) (2 << 8), - (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), - NULL); - hGraphWnd = CreateWindow(szGraphWinName, NULL, - WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER, - 0, 0, 0, 0, - hwnd, (HMENU) (4 << 8), - (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), - NULL); - - break; - case WM_DESTROY: /* end program */ - win32_go_away(); - break; - default: - return DefWindowProc(hwnd, message, wParam, lParam); - } - return 0; -} - -void CharOut(int c) { - TEXTMETRIC tm; - RECT r; - int xpos, ypos; - char nog[3]; - - sprintf(nog, "%c", c); - - if (x_coord < maxXChar && y_coord < maxYChar) - myScreen[(y_coord * maxXChar) + x_coord] = c; - - GetTextMetrics(memConDC, &tm); - xpos = tm.tmAveCharWidth * x_coord; - ypos = (tm.tmHeight + tm.tmExternalLeading) * y_coord; - - r.left = xpos; - r.right = (xpos + tm.tmAveCharWidth); - - r.top = ypos; - r.bottom = (ypos + tm.tmHeight + tm.tmExternalLeading); - - TextOut(memConDC, xpos, ypos, nog, 1); - TextOut(ConDC, xpos, ypos, nog, 1); -} - -int win32_putc(int c, FILE *strm) { - if (strm == stdout || strm == stderr) { - if (c == '\n') - win32_advance_line(); - else if (c == '\t') /* do nothing */ ; - else if (c == '\007') tone(400,30); - else { - if (x_coord == x_max) - new_line(strm); - CharOut(c); - } - return 0; - } - return putc(c, strm); -} - -void win32_charmode_on(void) { - char_mode = 1; -} - -void win32_charmode_off(void) { - char_mode = 0; -} - -void ibm_bold_mode(void) { - SetTextColor(memConDC, GetSysColor(COLOR_WINDOW)); - SetTextColor(ConDC, GetSysColor(COLOR_WINDOW)); - SetBkColor(memConDC, GetSysColor(COLOR_WINDOWTEXT)); - SetBkColor(ConDC, GetSysColor(COLOR_WINDOWTEXT)); -} - -void ibm_plain_mode(void) { - SetTextColor(memConDC, GetSysColor(COLOR_WINDOWTEXT)); - SetTextColor(ConDC, GetSysColor(COLOR_WINDOWTEXT)); - SetBkColor(memConDC, GetSysColor(COLOR_WINDOW)); - SetBkColor(ConDC, GetSysColor(COLOR_WINDOW)); -} - -NODE *set_text_color(NODE *args) { - int fore, back; - - fore = getint(pos_int_arg(args)); - if (NOT_THROWING) { - back = getint(pos_int_arg(cdr(args))); - if (NOT_THROWING) { - SetTextColor(memConDC, palette[2+fore]); - SetTextColor(ConDC, palette[2+fore]); - SetBkColor(memConDC, palette[2+back]); - SetBkColor(ConDC, palette[2+back]); - } - } - return UNBOUND; -} - -/* Thanks to George Mills for the tone code! */ -/* was: MessageBeep(0xffffffff); */ - -void tone(FIXNUM pitch, FIXNUM duration) { - OSVERSIONINFO VersionInformation; - unsigned char count_lo; - unsigned char count_hi; - FIXNUM count; - clock_t NumTicksToWait; - - memset(&VersionInformation, 0, sizeof(OSVERSIONINFO)); - VersionInformation.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (pitch < 37) pitch = 37; - GetVersionEx(&VersionInformation); - if (VersionInformation.dwPlatformId == VER_PLATFORM_WIN32_NT) - Beep(pitch, duration); - else { - count = 1193180L / pitch; - count_lo = LOBYTE(count); - count_hi = HIBYTE(count); - - _asm { - mov al, 0xB6 - out 0x43, al - mov al, count_lo - out 0x42, al - mov al, count_hi - out 0x42, al - xor al, al - in al, 0x61 - or al, 0x03 - out 0x61, al - } - - NumTicksToWait = duration + clock(); - while (NumTicksToWait > clock()); - - _asm { - xor al, al - in al, 0x61 - xor al, 0x03 - out 0x61, al - } - } -} diff --git a/win32trm.h b/win32trm.h deleted file mode 100644 index b8685740..00000000 --- a/win32trm.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*-C-*- - * Win32trm.h - * - * Function prototypes &c for Win32 API (Win95, WinNT) compliant - * procedures. - * - * $Id: win32trm.h,v 1.1.1.1 2005/02/01 19:47:31 paley Exp $ - * - * $Log: win32trm.h,v $ - * Revision 1.1.1.1 2005/02/01 19:47:31 paley - * initial commit - * - * - * (c) 1996 UC Regents, etc. - * - */ - -#include -#include "logo.h" - -#ifndef _WIN32TRM_H - -/* set to 1000 for debugging, should normally be ~10k */ -#define GR_SIZE 60000 - -#define prepare_to_draw win32_prepare_draw() -#define done_drawing - -#define prepare_to_draw_turtle win32_turtle_prep() -#define done_drawing_turtle win32_turtle_end() - -#define screen_left 0 -#define screen_right win32_screen_right() -#define screen_top 0 -#define screen_bottom win32_screen_bottom() -#define max_screen_bottom win32_screen_bottom() - -#define screen_height (1 + screen_bottom - screen_top) -#define screen_width (1 + screen_right - screen_left) - -#define screen_x_center (screen_left + (screen_width)/2) -#define screen_y_center (screen_top + (screen_height)/2) - -#define turtle_left_max ((screen_left) - (screen_x_center)) -#define turtle_right_max ((screen_right) - (screen_x_center)) -#define turtle_top_max ((screen_y_center) - (screen_top)) -#define turtle_bottom_max ((screen_y_center) - (screen_bottom)) - -#define screen_x_coord ((screen_x_center) + turtle_x) -#define screen_y_coord ((screen_y_center) - turtle_y) - -#define turtle_height (FIXNUM) 18 -#define turtle_half_bottom (FLONUM) 6.0 -#define turtle_side (FLONUM) 19.0 - -#define clear_screen win32_erase_screen() - -#define line_to(x,y) {\ - if (pen_vis==0) \ - lineto((int)x,(int)y); \ - else \ - moveto((int)x,(int)y);\ - } - -#define move_to(x,y) moveto((int)x,(int)y) -/* #define draw_string(s) outtext((char *)s) function */ - -#define set_pen_vis(v) { turtlePen.vis = v; } -/* functionified */ -#define set_pen_mode(m) win32_set_pen_mode(m) -/* functionified */ -#define set_pen_color(c) win32_set_pen_color(c) - -#define set_back_ground(c) win32_set_bg(c) -/* Now functions instead of macros */ -#define set_pen_width(w) win32_set_pen_width(w) -#define set_pen_height(h) win32_set_pen_width(h) - -#define set_pen_x(x) moveto((int)x, pen_y) -#define set_pen_y(y) moveto(pen_x, (int)y) - -#define erase_screen() win32_erase_screen() - -/* pen_info is a stucture type with fields for the various - pen characteristics including the location, size, color, - mode (e.g. XOR or COPY), pattern, visibility (0 = visible) */ - -typedef struct { int h; - int v; - int vis; - int width; - int color; - char pattern[8]; - int mode; -#ifdef WIN32 - HPEN hpen; -#endif -} pen_info; - -#define p_info_x(p) p.h -#define p_info_y(p) p.v - -#define pen_width (int) turtlePen.width -#define pen_height (int) turtlePen.width -#define pen_mode turtlePen.mode -#define pen_vis turtlePen.vis - -#define pen_x turtlePen.h -#define pen_y turtlePen.v - -#define get_node_pen_pattern win32_get_node_pen_pattern() - -#define pen_reverse win32_pen_reverse() -#define pen_erase win32_pen_erase() -#define pen_down win32_pen_down() - -#define button (w_button) - -#define full_screen win32_con_full_screen() -#define split_screen win32_con_split_screen() -#define text_screen win32_con_text_screen() - -/* definitions from term.c and math.c for ibmterm.c */ -extern int x_coord, y_coord, x_max, y_max, tty_charmode; -extern char so_arr[], se_arr[]; -extern FLONUM degrad; - -/* Forward declarations for graphics.c */ -extern void gr_mode(), draw_turtle(); -extern void win32_pen_erase(), win32_pen_down(), win32_pen_xor(); -extern void win32_set_pen_mode(int), win32_set_pen_color(), win32_set_bg(); -extern int get_win32_pen_mode(), win32_set_pen_width(int); -extern void save_pen(pen_info*), restore_pen(pen_info*), set_pen_pattern(); -extern void plain_xor_pen(); -extern void set_list_pen_pattern(), get_pen_pattern(), erase_screen(); -extern void label(), logofill(); -extern void t_screen(), s_screen(), f_screen(), tone(); -extern FIXNUM mickey_x(), mickey_y(); -extern NODE *win32_get_node_pen_pattern(); -extern FIXNUM t_height(); -extern FIXNUM pen_color, back_ground; -extern FLONUM t_half_bottom(), t_side(); -extern BOOLEAN in_erase_mode; -extern void win32_init_palette(), win32_pen_reverse(); -extern void win32_turtle_prep(), win32_turtle_end(); -extern void win32_con_text_screen(), win32_con_split_screen(); -extern void win32_prepare_draw(void); -extern void win32_con_full_screen(), win32_clear_text(); -extern NODE* win32_lsetcursor(NODE *); -extern int win32_screen_right(); -extern pen_info turtlePen; -extern void MoveCursor(int, int), win32_receive_char(char); -extern void win32_parse_line(char*); -extern FIXNUM mouse_x, mouse_y; -extern int w_button; - -/* prototypes added by sowings */ -extern BOOLEAN safe_to_save(); -extern void save_lm_helper(), save_line(), save_move(); -extern void save_mode(), save_color(), save_pattern(); -extern void save_size(), save_vis(); - -extern void set_palette(int, unsigned int, unsigned int, unsigned int); -extern void get_palette(int, unsigned int*, unsigned int*, unsigned int*); - -#define nop() {} - -#define WIN_PEN_ERASE 1 -#define WIN_PEN_DOWN 2 -#define WIN_PEN_REVERSE 3 - -#define NUM_LINES 100 -#define CHARS_PER_LINE 200 - -LRESULT CALLBACK MainFunc(HWND, UINT, WPARAM, LPARAM); - -#define _WIN32TRM_H -#endif /* !_WIN32TRM_H */ diff --git a/winbuild.sh b/winbuild.sh index 75db6a64..505898a3 100644 --- a/winbuild.sh +++ b/winbuild.sh @@ -9,5 +9,4 @@ export WX_DIR=/home/User/wxWidgets-3.2.2.1 mingw32-make -f makefile.msys clean mingw32-make -f makefile.msys git.c -rm libloc.c mingw32-make -f makefile.msys MINGW_BIN_DIR=$MINGW_BIN_DIR WX_DIR=$WX_DIR install_win \ No newline at end of file diff --git a/wrksp.c b/wrksp.c index 453a7b00..718e39d6 100644 --- a/wrksp.c +++ b/wrksp.c @@ -42,16 +42,14 @@ long wxLaunchExternalEditor(char *, char *); #include #endif -#ifdef HAVE_TERMIO_H -#ifdef HAVE_WX +#if defined(HAVE_TERMIOS_H) #include -#else +#elif defined(HAVE_TERMIO_H) #include #endif -#else -#ifdef HAVE_SGTTY_H -#include -#endif + +#ifdef HAVE_SYS_IOCTL_H +#include #endif #ifdef HAVE_WX @@ -1863,11 +1861,6 @@ NODE *lhelp(NODE *args) { int lines; if (args == NIL) { -/* - #ifdef WIN32 - sprintf(buffer, "%sHELPCONT", addsep(helpfiles)); - #else - */ sprintf(buffer, "%sHELPCONTENTS", addsep(helpfiles)); /* #endif */ } else if (is_word(car(args)) && car(args) != Null_Word) { @@ -1924,9 +1917,6 @@ NODE *lhelp(NODE *args) { #endif ndprintf(writestream, message_texts[MORE_HELP]); input_blocking++; -#ifndef TIOCSTI - if (!setjmp(iblk_buf)) -#endif #ifdef WIN32 (void)reader(stdin, ""); #else diff --git a/wxterm.c b/wxterm.c index 02a25046..de55eba1 100644 --- a/wxterm.c +++ b/wxterm.c @@ -31,10 +31,6 @@ #ifdef HAVE_TERMIO_H #include -#else -#ifdef HAVE_SGTTY_H -#include -#endif #endif #undef TRUE @@ -68,14 +64,6 @@ char cm_arr[40]; char so_arr[40]; char se_arr[40]; -#ifdef HAVE_TERMIO_H -struct termios tty_cooked, tty_cbreak; -#else -#ifdef HAVE_SGTTY_H -struct sgttyb tty_cooked, tty_cbreak; -#endif -#endif - int interactive, tty_charmode; int getTermInfo(int type); int setTermInfo(int type, int val);