From 7303bfcc594fec80f49c02725214665321aee9d8 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Fri, 1 May 2020 20:07:31 +0000
Subject: [PATCH] Add a LeftJustify INI-only option. If the syncterm.ini file
 has LeftJustify=TRUE in it, non-exact modes (ie: curses) will print against
 the left margin, and the sides won't be filled with blue.

This change really highlights just how bad the term struct is, and this
won't become an official option until after the 1.1 release and a serious
overhaul of this stuff occurs.
---
 src/syncterm/syncterm.c |  1 +
 src/syncterm/syncterm.h |  1 +
 src/syncterm/window.c   | 17 +++++++++++------
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/syncterm/syncterm.c b/src/syncterm/syncterm.c
index a6c377132a..b62f2d51a4 100644
--- a/src/syncterm/syncterm.c
+++ b/src/syncterm/syncterm.c
@@ -1238,6 +1238,7 @@ void load_settings(struct syncterm_settings *set)
 	set->scaling_factor=iniReadInteger(inifile,"SyncTERM","ScalingFactor",0);
 	set->window_width=iniReadInteger(inifile,"SyncTERM","WindowWidth",0);
 	set->window_height=iniReadInteger(inifile,"SyncTERM","WindowHeight",0);
+	set->left_just=iniReadBool(inifile,"SyncTERM","LeftJustify",FALSE);
 
 	/* Modem settings */
 	iniReadString(inifile, "SyncTERM", "ModemInit", "AT&F&C1&D2", set->mdm.init_string);
diff --git a/src/syncterm/syncterm.h b/src/syncterm/syncterm.h
index a28bedf886..2e7b48353d 100644
--- a/src/syncterm/syncterm.h
+++ b/src/syncterm/syncterm.h
@@ -64,6 +64,7 @@ struct syncterm_settings {
 	int		custom_fontheight;
 	int		window_width;
 	int		window_height;
+	int		left_just;
 };
 
 extern char *inpath;
diff --git a/src/syncterm/window.c b/src/syncterm/window.c
index f76c7640e9..ba23d62ca5 100644
--- a/src/syncterm/window.c
+++ b/src/syncterm/window.c
@@ -14,7 +14,7 @@ int drawwin(void)
 	char	str[32];
 	int		x,y,c;
 
-    gettextinfo(&txtinfo);
+	gettextinfo(&txtinfo);
 
 	strcpy(str,"         ");
 
@@ -33,15 +33,17 @@ int drawwin(void)
 		term.height=24;
 		term.nostatus=1;
 	}
-	term.x=(txtinfo.screenwidth-term.width)/2+2;
+	if (settings.left_just)
+		term.x = 2;
+	else
+		term.x=(txtinfo.screenwidth-term.width)/2+2;
 	term.y=(txtinfo.screenheight-term.height)/2+2;
 	if((winbuf=(char *)alloca(txtinfo.screenheight*txtinfo.screenwidth*2))==NULL) {
 		uifcmsg("Cannot allocate memory for terminal buffer",	"`Memory error`\n\n"
-																"Either your system is dangerously low on resources or your\n"
-																"window is farking huge!");
+		    "Either your system is dangerously low on resources or your\n"
+		    "window is farking huge!");
 		return(-1);
 	}
-
 	c=0;
 	for(y=0;y<txtinfo.screenheight;y++) {
 		p=str;
@@ -54,7 +56,10 @@ int drawwin(void)
 			winbuf[c++]=*(p++);
 			if(!*p)
 				p=str;
-			winbuf[c++]=YELLOW|(BLUE<<4);
+			if (settings.left_just)
+				winbuf[c++]=0;
+			else
+				winbuf[c++]=YELLOW|(BLUE<<4);
 		}
 	}
 	puttext(1,1,txtinfo.screenwidth,txtinfo.screenheight,winbuf);
-- 
GitLab