SDL_net: Removed dependency on GUIlib

From 21b18f6d6384b77c3a8dd0358379d5d60b8f61e8 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 20 Jun 2022 19:09:28 -0700
Subject: [PATCH] Removed dependency on GUIlib

---
 Makefile.am        |  11 +-
 Makefile.in        |  60 +-------
 aclocal.m4         | 100 +++++++++++++
 chat.cpp => chat.c | 366 +++++++++++++++++++++++++++------------------
 configure          | 147 ++++--------------
 configure.ac       |  21 ---
 quit.bmp           | Bin 12342 -> 0 bytes
 scroll_dn.bmp      | Bin 3126 -> 0 bytes
 scroll_up.bmp      | Bin 3126 -> 0 bytes
 9 files changed, 359 insertions(+), 346 deletions(-)
 rename chat.cpp => chat.c (58%)
 delete mode 100644 quit.bmp
 delete mode 100644 scroll_dn.bmp
 delete mode 100644 scroll_up.bmp

diff --git a/Makefile.am b/Makefile.am
index 8db5efc..04e20b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,9 +23,6 @@ EXTRA_DIST = CHANGES.txt LICENSE.txt README.txt \
 	VisualC			\
 	Xcode			\
 	Xcode-iOS		\
-	quit.bmp		\
-	scroll_dn.bmp		\
-	scroll_up.bmp		\
 	SDL2_net.spec		\
 	SDL2_net.spec.in	\
 	autogen.sh	\
@@ -45,17 +42,13 @@ endif
 .rc.o:
 	$(RC) $< $@
 
-if HAVE_GUI_LIB
 EXAMPLES = showinterfaces chat chatd
-else
-EXAMPLES = showinterfaces
-endif
 noinst_PROGRAMS = $(EXAMPLES)
 
 showinterfaces_SOURCES = showinterfaces.c
 showinterfaces_LDADD = libSDL2_net.la
-chat_SOURCES = chat.cpp chat.h
-chat_LDADD = libSDL2_net.la -lGUI
+chat_SOURCES = chat.c chat.h
+chat_LDADD = libSDL2_net.la -lSDL2_test
 chatd_SOURCES = chatd.c
 chatd_LDADD = libSDL2_net.la
 
diff --git a/Makefile.in b/Makefile.in
index 7df616f..456b721 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -113,9 +113,7 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_CLEAN_FILES = sdl2_net-config.cmake \
 	sdl2_net-config-version.cmake SDL2_net.spec SDL2_net.pc
 CONFIG_CLEAN_VPATH_FILES =
-@HAVE_GUI_LIB_FALSE@am__EXEEXT_1 = showinterfaces$(EXEEXT)
-@HAVE_GUI_LIB_TRUE@am__EXEEXT_1 = showinterfaces$(EXEEXT) \
-@HAVE_GUI_LIB_TRUE@	chat$(EXEEXT) chatd$(EXEEXT)
+am__EXEEXT_1 = showinterfaces$(EXEEXT) chat$(EXEEXT) chatd$(EXEEXT)
 PROGRAMS = $(noinst_PROGRAMS)
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
@@ -205,24 +203,6 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
-CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
-	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
-	$(AM_CXXFLAGS) $(CXXFLAGS)
-AM_V_CXX = $(am__v_CXX_@AM_V@)
-am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
-am__v_CXX_0 = @echo "  CXX     " $@;
-am__v_CXX_1 = 
-CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
-am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
-am__v_CXXLD_0 = @echo "  CXXLD   " $@;
-am__v_CXXLD_1 = 
 SOURCES = $(libSDL2_net_la_SOURCES) $(chat_SOURCES) $(chatd_SOURCES) \
 	$(showinterfaces_SOURCES)
 DIST_SOURCES = $(libSDL2_net_la_SOURCES) $(chat_SOURCES) \
@@ -446,9 +426,6 @@ EXTRA_DIST = CHANGES.txt LICENSE.txt README.txt \
 	VisualC			\
 	Xcode			\
 	Xcode-iOS		\
-	quit.bmp		\
-	scroll_dn.bmp		\
-	scroll_up.bmp		\
 	SDL2_net.spec		\
 	SDL2_net.spec.in	\
 	autogen.sh	\
@@ -463,12 +440,11 @@ libSDL2_net_la_LDFLAGS = \
 
 libSDL2_net_la_LIBADD = @INETLIB@
 @USE_VERSION_RC_TRUE@libSDL2_net_la_DEPENDENCIES = version.o
-@HAVE_GUI_LIB_FALSE@EXAMPLES = showinterfaces
-@HAVE_GUI_LIB_TRUE@EXAMPLES = showinterfaces chat chatd
+EXAMPLES = showinterfaces chat chatd
 showinterfaces_SOURCES = showinterfaces.c
 showinterfaces_LDADD = libSDL2_net.la
-chat_SOURCES = chat.cpp chat.h
-chat_LDADD = libSDL2_net.la -lGUI
+chat_SOURCES = chat.c chat.h
+chat_LDADD = libSDL2_net.la -lSDL2_test
 chatd_SOURCES = chatd.c
 chatd_LDADD = libSDL2_net.la
 pkgconfigdir = $(libdir)/pkgconfig
@@ -476,7 +452,7 @@ pkgconfig_DATA = SDL2_net.pc
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .c .cpp .lo .o .obj .rc
+.SUFFIXES: .c .lo .o .obj .rc
 am--refresh: Makefile
 	@:
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
@@ -568,7 +544,7 @@ libSDL2_net.la: $(libSDL2_net_la_OBJECTS) $(libSDL2_net_la_DEPENDENCIES) $(EXTRA
 
 chat$(EXEEXT): $(chat_OBJECTS) $(chat_DEPENDENCIES) $(EXTRA_chat_DEPENDENCIES) 
 	@rm -f chat$(EXEEXT)
-	$(AM_V_CXXLD)$(CXXLINK) $(chat_OBJECTS) $(chat_LDADD) $(LIBS)
+	$(AM_V_CCLD)$(LINK) $(chat_OBJECTS) $(chat_LDADD) $(LIBS)
 
 chatd$(EXEEXT): $(chatd_OBJECTS) $(chatd_DEPENDENCIES) $(EXTRA_chatd_DEPENDENCIES) 
 	@rm -f chatd$(EXEEXT)
@@ -622,30 +598,6 @@ am--depfiles: $(am__depfiles_remade)
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
 
-.cpp.o:
-@am__fastdepCXX_TRUE@	$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
-@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
-@am__fastdepCXX_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
-
-.cpp.obj:
-@am__fastdepCXX_TRUE@	$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
-@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
-@am__fastdepCXX_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.cpp.lo:
-@am__fastdepCXX_TRUE@	$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
-@am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
-@am__fastdepCXX_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
-
 mostlyclean-libtool:
 	-rm -f *.lo
 
diff --git a/aclocal.m4 b/aclocal.m4
index 782d9ec..8a5c40d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -20,6 +20,106 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
+#
+#   Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
+#   Foundation, Inc.
+#   Written by Scott James Remnant, 2004.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 5 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else.  This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION],	[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP],		[AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT],		[AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],	[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN],		[AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR],		[AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL],	[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN],		[AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER],	[AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK],		[AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],	[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],	[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],	[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR],		[AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR],		[AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],	[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC],		[AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU],		[AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG],	[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD],	[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],	[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],	[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP],		[AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED],		[AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME],		[AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE],	[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE],	[AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL],		[AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP],		[AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN],		[AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],	[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG],		[AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL],	[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX],		[AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77],		[AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ],		[AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG],	[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG],	[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG],	[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],	[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG],	[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG],		[AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C],	[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
+m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],	[AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
+m4_ifndef([_LT_AC_PROG_CXXCPP],		[AC_DEFUN([_LT_AC_PROG_CXXCPP])])
+m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],	[AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
+m4_ifndef([_LT_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_PROG_F77],		[AC_DEFUN([_LT_PROG_F77])])
+m4_ifndef([_LT_PROG_FC],		[AC_DEFUN([_LT_PROG_FC])])
+m4_ifndef([_LT_PROG_CXX],		[AC_DEFUN([_LT_PROG_CXX])])
+
 # Copyright (C) 2002-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
diff --git a/chat.cpp b/chat.c
similarity index 58%
rename from chat.cpp
rename to chat.c
index 08a32da..798892c 100644
--- a/chat.cpp
+++ b/chat.c
@@ -29,13 +29,7 @@
 #include <string.h>
 
 #include "SDL_net.h"
-#ifdef macintosh
-#include "GUI.h"
-#include "GUI_widgets.h"
-#else
-#include <GUI/GUI.h>
-#include <GUI/GUI_widgets.h>
-#endif
+#include "SDL_test.h"
 #include "chat.h"
 
 
@@ -49,20 +43,132 @@ static struct {
     Uint8 name[256+1];
 } people[CHAT_MAXPEOPLE];
 
-static GUI *gui = NULL;
-static GUI_TermWin *termwin;
-static GUI_TermWin *sendwin;
-enum image_names {
-    IMAGE_QUIT,
-    IMAGE_SCROLL_UP,
-    IMAGE_SCROLL_DN,
-    NUM_IMAGES
-};
-const char *image_files[NUM_IMAGES] = {
-    "quit.bmp", "scroll_up.bmp", "scroll_dn.bmp"
-};
-SDL_Surface *images[NUM_IMAGES];
+static char keybuf[80-sizeof(CHAT_PROMPT)+1];
+static int  keypos = 0;
 
+#define FONT_LINE_HEIGHT    (FONT_CHARACTER_SIZE + 2)
+
+typedef struct
+{
+    SDL_Rect rect;
+    int current;
+    int numlines;
+    char **lines;
+
+} TextWindow;
+
+static TextWindow *termwin;
+static TextWindow *sendwin;
+
+static TextWindow *TextWindowCreate(int x, int y, int w, int h)
+{
+    TextWindow *textwin = (TextWindow *)SDL_malloc(sizeof(*textwin));
+
+    if ( !textwin ) {
+        return NULL;
+    }
+
+    textwin->rect.x = x;
+    textwin->rect.y = y;
+    textwin->rect.w = w;
+    textwin->rect.h = h;
+    textwin->current = 0;
+    textwin->numlines = (h / FONT_LINE_HEIGHT);
+    textwin->lines = (char **)SDL_calloc(textwin->numlines, sizeof(*textwin->lines));
+    if ( !textwin->lines ) {
+        SDL_free(textwin);
+        return NULL;
+    }
+    return textwin;
+}
+
+static void TextWindowDisplay(TextWindow *textwin, SDL_Renderer *renderer)
+{
+    int i, y;
+
+    SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
+    for ( y = textwin->rect.y, i = 0; i < textwin->numlines; ++i, y += FONT_LINE_HEIGHT ) {
+        if ( textwin->lines[i] ) {
+            SDLTest_DrawString(renderer, textwin->rect.x, y, textwin->lines[i]);
+        }
+    }
+}
+
+static void TextWindowAddTextWithLength(TextWindow *textwin, const char *text, size_t len)
+{
+    size_t existing;
+    SDL_bool newline = SDL_FALSE;
+    char *line;
+
+    if ( len > 0 && text[len - 1] == '\n' ) {
+        --len;
+        newline = SDL_TRUE;
+    }
+
+    if ( textwin->lines[textwin->current] ) {
+        existing = SDL_strlen(textwin->lines[textwin->current]);
+    } else {
+        existing = 0;
+    }
+
+    if ( *text == '\b' ) {
+        if ( existing ) {
+            textwin->lines[textwin->current][existing - 1] = '\0';
+        }
+        return;
+    }
+
+    line = (char *)SDL_realloc(textwin->lines[textwin->current], existing + len + 1);
+    if ( line ) {
+        SDL_memcpy(&line[existing], text, len);
+        line[existing + len] = '\0';
+        textwin->lines[textwin->current] = line;
+        if ( newline ) {
+            if (textwin->current == textwin->numlines - 1) {
+                SDL_free(textwin->lines[0]);
+                SDL_memcpy(&textwin->lines[0], &textwin->lines[1], (textwin->numlines-1) * sizeof(textwin->lines[1]));
+                textwin->lines[textwin->current] = NULL;
+            } else {
+                ++textwin->current;
+            }
+        }
+    }
+}
+
+static void TextWindowAddText(TextWindow *textwin, const char *fmt, ...)
+{
+	char text[1024];
+	va_list ap;
+
+	va_start(ap, fmt);
+	SDL_vsnprintf(text, sizeof(text), fmt, ap);
+	va_end(ap);
+
+    TextWindowAddTextWithLength(textwin, text, SDL_strlen(text));
+}
+
+static void TextWindowClear(TextWindow *textwin)
+{
+    int i;
+
+    for ( i = 0; i < textwin->numlines; ++i )
+    {
+        if ( textwin->lines[i] ) {
+            SDL_free(textwin->lines[i]);
+            textwin->lines[i] = NULL;
+        }
+    }
+    textwin->current = 0;
+}
+
+static void TextWindowDestroy(TextWindow *textwin)
+{
+    if ( textwin ) {
+        TextWindowClear(textwin);
+        SDL_free(textwin->lines);
+        SDL_free(textwin);
+    }
+}
 
 void SendHello(const char *name)
 {
@@ -81,7 +187,7 @@ void SendHello(const char *name)
              ((name=getenv("USER")) == NULL ) ) {
             name="Unknown";
         }
-        termwin->AddText("Using name '%s'\n", name);
+        TextWindowAddText(termwin, "Using name '%s'\n", name);
 
         /* Construct the packet */
         hello[0] = CHAT_HELLO;
@@ -106,8 +212,8 @@ void SendBuf(char *buf, int len)
     int i;
 
     /* Redraw the prompt and add a newline to the buffer */
-    sendwin->Clear();
-    sendwin->AddText(CHAT_PROMPT);
+    TextWindowClear(sendwin);
+    TextWindowAddText(sendwin, CHAT_PROMPT);
     buf[len++] = '\n';
 
     /* Send the text to each of our active channels */
@@ -122,45 +228,6 @@ void SendBuf(char *buf, int len)
         }
     }
 }
-void SendKey(SDL_Keycode key, Uint16 unicode)
-{
-    static char keybuf[80-sizeof(CHAT_PROMPT)+1];
-    static int  keypos = 0;
-    char ch;
-
-    switch (key) {
-    case SDLK_RETURN:
-        /* Send our line of text */
-        SendBuf(keybuf, keypos);
-        keypos = 0;
-        break;
-    case SDLK_BACKSPACE:
-        /* If there's data, back up over it */
-        if ( keypos > 0 ) {
-            ch = '\b';
-            sendwin->AddText(&ch, 1);
-            --keypos;
-        }
-        break;
-    default:
-        break;
-    }
-
-    /* We don't handle non-ASCII characters yet */
-    if ( unicode == 0 || unicode > 127 ) {
-        return;
-    }
-    ch = (char)unicode;
-
-    /* If the buffer is full, send it */
-    if ( keypos == (sizeof(keybuf)/sizeof(keybuf[0]))-1 ) {
-        SendBuf(keybuf, keypos);
-        keypos = 0;
-    }
-    /* Add the text to our send buffer */
-    sendwin->AddText((char *)&ch, 1);
-    keybuf[keypos++] = ch;
-}
 
 int HandleServerData(Uint8 *data)
 {
@@ -187,7 +254,7 @@ int HandleServerData(Uint8 *data)
             people[which].active = 1;
 
             /* Let the user know what happened */
-            termwin->AddText(
+            TextWindowAddText(termwin,
     "* New client on %d from %d.%d.%d.%d:%d (%s)\n", which,
         (newip.host>>24)&0xFF, (newip.host>>16)&0xFF,
             (newip.host>>8)&0xFF, newip.host&0xFF,
@@ -215,7 +282,7 @@ int HandleServerData(Uint8 *data)
             people[which].active = 0;
 
             /* Let the user know what happened */
-            termwin->AddText(
+            TextWindowAddText(termwin,
     "* Lost client on %d (%s)\n", which, people[which].name);
 
             /* Unbind the address on the UDP socket */
@@ -224,7 +291,7 @@ int HandleServerData(Uint8 *data)
         used = CHAT_DEL_LEN;
         break;
         case CHAT_BYE: {
-            termwin->AddText("* Chat server full\n");
+            TextWindowAddText(termwin, "* Chat server full\n");
         }
         used = CHAT_BYE_LEN;
         break;
@@ -249,7 +316,7 @@ void HandleServer(void)
         SDLNet_TCP_DelSocket(socketset, tcpsock);
         SDLNet_TCP_Close(tcpsock);
         tcpsock = NULL;
-        termwin->AddText("Connection with server lost!\n");
+        TextWindowAddText(termwin, "Connection with server lost!\n");
     } else {
         pos = 0;
         while ( len > 0 ) {
@@ -272,14 +339,14 @@ void HandleClient(void)
     n = SDLNet_UDP_RecvV(udpsock, packets);
     while ( n-- > 0 ) {
         if ( packets[n]->channel >= 0 ) {
-            termwin->AddText("[%s] ",
+            TextWindowAddText(termwin, "[%s] ",
                 people[packets[n]->channel].name);
-            termwin->AddText((char *)packets[n]->data, packets[n]->len);
+            TextWindowAddTextWithLength(termwin, (char *)packets[n]->data, packets[n]->len);
         }
     }
 }
 
-GUI_status HandleNet(void)
+void HandleNet(void)
 {
     SDLNet_CheckSockets(socketset, 0);
     if ( SDLNet_SocketReady(tcpsock) ) {
@@ -288,65 +355,39 @@ GUI_status HandleNet(void)
     if ( SDLNet_SocketReady(udpsock) ) {
         HandleClient();
     }
-
-    /* Redraw the screen if the window changed */
-    if ( termwin->Changed() ) {
-        return(GUI_REDRAW);
-    } else {
-        return(GUI_PASS);
-    }
 }
 
-void InitGUI(SDL_Window *window)
+void InitGUI(int width, int height)
 {
-    SDL_Surface *screen = SDL_GetWindowSurface(window);
-    int x1, y1, y2;
-    SDL_Rect empty_rect = { 0, 0, 0, 0 };
-    GUI_Widget *widget;
-
-    gui = new GUI(window);
+    int lines = (height / FONT_LINE_HEIGHT) - 2;
 
     /* Chat terminal window */
-    termwin = new GUI_TermWin(0, 0, 80*8, 50*8, NULL,NULL,CHAT_SCROLLBACK);
-    gui->AddWidget(termwin);
+    termwin = TextWindowCreate(2, 2, width-4, lines*FONT_LINE_HEIGHT);
 
     /* Send-line window */
-    y1 = termwin->H()+2;
-    sendwin = new GUI_TermWin(0, y1, 80*8, 1*8, NULL, SendKey, 0);
-    sendwin->AddText(CHAT_PROMPT);
-    gui->AddWidget(sendwin);
-
-    /* Add scroll buttons for main window */
-    y1 += sendwin->H()+2;
-    y2 = y1+images[IMAGE_SCROLL_UP]->h;
-    widget = new GUI_ScrollButtons(2, y1, images[IMAGE_SCROLL_UP],
-                       empty_rect, 2, y2, images[IMAGE_SCROLL_DN],
-                    SCROLLBAR_VERTICAL, termwin);
-    gui->AddWidget(widget);
-
-    /* Add QUIT button */
-    x1 = (screen->w-images[IMAGE_QUIT]->w)/2;
-    y1 = sendwin->Y()+sendwin->H()+images[IMAGE_QUIT]->h/2;
-    widget = new GUI_Button(NULL, x1, y1, images[IMAGE_QUIT], NULL);
-    gui->AddWidget(widget);
+    sendwin = TextWindowCreate(2, 2+lines*FONT_LINE_HEIGHT+2, width-4, 1*FONT_LINE_HEIGHT);
+    TextWindowAddText(sendwin, CHAT_PROMPT);
 }
 
-extern "C"
-void cleanup(int exitcode)
+void DisplayGUI(SDL_Renderer *renderer)
 {
-    int i;
+    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+    SDL_RenderClear(renderer);
+    TextWindowDisplay(termwin, renderer);
+    TextWindowDisplay(sendwin, renderer);
+    SDL_RenderPresent(renderer);
+}
 
+void cleanup(int exitcode)
+{
     /* Clean up the GUI */
-    if ( gui ) {
-            delete gui;
-        gui = NULL;
-    }
-    /* Clean up any images we have */
-    for ( i=0; i<NUM_IMAGES; ++i ) {
-        if ( images[i] ) {
-            SDL_FreeSurface(images[i]);
-            images[i] = NULL;
-        }
+    if ( termwin ) {
+        TextWindowDestroy( termwin );
+        termwin = NULL;
+    }
+    if ( sendwin ) {
+        TextWindowDestroy( sendwin );
+        sendwin = NULL;
     }
     /* Close the network connections */
     if ( tcpsock != NULL ) {
@@ -373,9 +414,11 @@ void cleanup(int exitcode)
 int main(int argc, char *argv[])
 {
     SDL_Window *window;
-    int i;
+    SDL_Renderer *renderer;
+    int i, done;
     char *server;
     IPaddress serverIP;
+    SDL_Event event;
 
     /* Check command line arguments */
     if ( argv[1] == NULL ) {
@@ -389,9 +432,8 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
-    /* Set a 640x480 video mode -- allows 80x50 window using 8x8 font */
-    window = SDL_CreateWindow("Chat", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0);
-    if ( window == NULL ) {
+    /* Set a 640x480 video mode */
+    if ( SDL_CreateWindowAndRenderer(640, 480, 0, &window, &renderer) < 0 ) {
         fprintf(stderr, "Couldn't create window: %s\n",SDL_GetError());
         SDL_Quit();
         exit(1);
@@ -405,23 +447,8 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
-    /* Get ready to initialize all of our data */
-
-    /* Load the display font and other images */
-    for ( i=0; i<NUM_IMAGES; ++i ) {
-        images[i] = NULL;
-    }
-    for ( i=0; i<NUM_IMAGES; ++i ) {
-        images[i] = SDL_LoadBMP(image_files[i]);
-        if ( images[i] == NULL ) {
-            fprintf(stderr, "Couldn't load '%s': %s\n",
-                    image_files[i], SDL_GetError());
-            cleanup(2);
-        }
-    }
-
     /* Go! */
-    InitGUI(window);
+    InitGUI(640, 480);
 
     /* Allocate a vector of packets for client messages */
     packets = SDLNet_AllocPacketV(4, CHAT_PACKETSIZE);
@@ -432,18 +459,18 @@ int main(int argc, char *argv[])
 
     /* Connect to remote host and create UDP endpoint */
     server = argv[1];
-    termwin->AddText("Connecting to %s ... ", server);
-    gui->Display();
+    TextWindowAddText(termwin, "Connecting to %s ... ", server);
+    DisplayGUI(renderer);
     SDLNet_ResolveHost(&serverIP, server, CHAT_PORT);
     if ( serverIP.host == INADDR_NONE ) {
-        termwin->AddText("Couldn't resolve hostname\n");
+        TextWindowAddText(termwin, "Couldn't resolve hostname\n");
     } else {
         /* If we fail, it's okay, the GUI shows the problem */
         tcpsock = SDLNet_TCP_Open(&serverIP);
         if ( tcpsock == NULL ) {
-            termwin->AddText("Connect failed\n");
+            TextWindowAddText(termwin, "Connect failed\n");
         } else {
-            termwin->AddText("Connected\n");
+            TextWindowAddText(termwin, "Connected\n");
         }
     }
     /* Try ports in the range {CHAT_PORT - CHAT_PORT+10} */
@@ -453,7 +480,7 @@ int main(int argc, char *argv[])
     if ( udpsock == NULL ) {
         SDLNet_TCP_Close(tcpsock);
         tcpsock = NULL;
-        termwin->AddText("Couldn't create UDP endpoint\n");
+        TextWindowAddText(termwin, "Couldn't create UDP endpoint\n");
     }
 
     /* Allocate the socket set for polling the network */
@@ -468,7 +495,60 @@ int main(int argc, char *argv[])
 
     /* Run the GUI, handling network data */
     SendHello(argv[2]);
-    gui->Run(HandleNet);
+    done = 0;
+    while ( !done ) {
+        HandleNet();
+
+        while ( SDL_PollEvent(&event) == 1 ) {
+            switch ( event.type ) {
+            case SDL_QUIT:
+                done = 1;
+                break;
+            case SDL_KEYDOWN:
+                switch ( event.key.keysym.sym ) {
+                case SDLK_ESCAPE:
+                    done = 1;
+                    break;
+                case SDLK_RETURN:
+                    /* Send our line of text */
+                    SendBuf(keybuf, keypos);
+                    keypos = 0;
+                    break;
+                case SDLK_BACKSPACE:
+                    /* If there's data, back up over it */
+                    if ( keypos > 0 ) {
+                        TextWindowAddText(sendwin, "\b", 1);
+                        --keypos;
+                    }
+                    break;
+                default:
+                    break;
+                }
+                break;
+            case SDL_TEXTINPUT:
+                {
+                    size_t textlen = SDL_strlen(event.text.text);
+
+                    if ( textlen < sizeof(keybuf) ) {
+                        /* If the buffer is full, send it */
+                        if ( (keypos + textlen) >= sizeof(keybuf) ) {
+                            SendBuf(keybuf, keypos);
+                            keypos = 0;
+                        }
+                        /* Add the text to our send buffer */
+                        TextWindowAddText(sendwin, event.text.text, textlen);
+                        SDL_memcpy(&keybuf[keypos], event.text.text, textlen);
+                        keypos += textlen;
+                    }
+                }
+                break;
+            default:
+                break;
+            }
+        }
+
+        DisplayGUI(renderer);
+    }
     cleanup(0);
 
     /* Keep the compiler happy */
diff --git a/configure b/configure
index fd862bf..4097da2 100755
--- a/configure
+++ b/configure
@@ -807,8 +807,6 @@ ENABLE_STATIC_TRUE
 ENABLE_SHARED_FALSE
 ENABLE_SHARED_TRUE
 cmake_prefix_relpath
-HAVE_GUI_LIB_FALSE
-HAVE_GUI_LIB_TRUE
 SDL2_CONFIG
 SDL_LIBS
 SDL_CFLAGS
@@ -966,7 +964,6 @@ enable_silent_rules
 with_sdl_prefix
 with_sdl_exec_prefix
 enable_sdltest
-enable_gui
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1624,7 +1621,6 @@ Optional Features:
   --enable-silent-rules   less verbose build output (undo: "make V=1")
   --disable-silent-rules  verbose build output (undo: "make V=0")
   --disable-sdltest       Do not try to compile and run a test SDL program
-  --enable-gui            Try to build the GUI test programs [default=yes]
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -4889,13 +4885,13 @@ then :
 else $as_nop
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:4892: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:4888: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4895: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:4891: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4898: output\"" >&5)
+  (eval echo "\"\$as_me:4894: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6154,7 +6150,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6157 "configure"' > conftest.$ac_ext
+  echo '#line 6153 "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7827,11 +7823,11 @@ else $as_nop
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7830: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7826: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7834: \$? = $ac_status" >&5
+   echo "$as_me:7830: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8177,11 +8173,11 @@ else $as_nop
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8180: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8176: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8184: \$? = $ac_status" >&5
+   echo "$as_me

(Patch may be truncated, please check the link at the top of this post.)