From c3e97f645ca08946d3230142d74379a1909069b0 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (in GitKraken)" <rob@synchro.net>
Date: Thu, 16 Feb 2023 14:30:46 -0800
Subject: [PATCH] Fix centering of the showbuf (e.g. help screen) title

I'm not sure what was going on with this addition of 6 when mouse is enabled (and didn't check for WIN_DYN flag set!), but is wrong. And we need to add 4 to the title_len when figuring out the centered-offset.
---
 src/uifc/uifc32.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c
index a751e8ece6..6245184227 100644
--- a/src/uifc/uifc32.c
+++ b/src/uifc/uifc32.c
@@ -2740,8 +2740,6 @@ void showbuf(uifc_winmode_t mode, int left, int top, int width, int height, cons
 	_setcursortype(_NOCURSOR);
 
 	title_len=strlen(title);
-	if(api->mode&UIFC_MOUSE)
-		title_len+=6;
 
 	if((unsigned)(top+height)>=api->scrn_len)
 		height = api->scrn_len - top;
@@ -2788,7 +2786,7 @@ void showbuf(uifc_winmode_t mode, int left, int top, int width, int height, cons
 		for(i=0; i<width*height; i++)
 			set_vmem(&tmp_buffer2[i], ' ', api->hclr|(api->bclr<<4), 0);
 		tmp_buffer2[0].ch=api->chars->help_top_left;
-		j=title_len;
+		j=title_len + 4; // Account for title breaks and spaces
 		if(j>width-6) {
 			j=width-6;
 		}
-- 
GitLab