From 54574148f3cd9c566b0617e5e90c487f354c2dbd Mon Sep 17 00:00:00 2001
From: Ian Jones <
[email protected]>
Date: Mon, 3 Mar 2025 12:44:00 +0100
Subject: [PATCH] Removed selected item indicator '-->' from left margin,
replaced with curses A_REVERSE. Reduced left margin and made static at 8
characters, allowing 6 index digits for selectors upto 999999. Hopefully
corrected incorrect accounting of title line length, my titles were truncated
even though 69 characters in length.
Removed part of truncation function which removed characters after the first
'/' in lines determined to be too long. This an unexpected behavior, it should
be up to the author how the menu lines appear.
Made a change to the counting of characters where truncated. After making a
maxlength truncation we were adding two more characters '..' causing the line
to again be too long to display.
---
gopher/manager.c | 55 ++++++++++++++++++------------------------------
1 file changed, 20 insertions(+), 35 deletions(-)
diff --git a/gopher/manager.c b/gopher/manager.c
index 941328f..b139954 100644
--- a/gopher/manager.c
+++ b/gopher/manager.c
@@ -151,6 +151,9 @@
#include "manager.h"
#include "util.h"
+static int MenuMargin = 8;
+static int MenuLineMax = 69;
+
#ifdef NOBANNER
# define MENULINE(x) (x)+1
#else
@@ -219,9 +222,8 @@ void
DisplayTitle(GopherObj *gs, int maxlength, boolean dogplus)
{
char type;
- char *c, *d;
+ char *d;
char *size;
- int m,n;
char temp[1024];
type = GSgetType(gs);
@@ -271,23 +273,13 @@ DisplayTitle(GopherObj *gs, int maxlength, boolean dogplus)
if (d==NULL)
d = "error";
-
- if((m = strlen(d)) <= maxlength)
- printw(" %s", d);
- else {
- /*** Cut out the middle bits **/
- if ((c = strchr(d, '/'))!=NULL && (maxlength > (c-d))) {
- n = c - d;
- strncpy(temp, d, n);
- strcpy(temp + n, "..");
- strcat(temp, d + (m + n - maxlength));
- printw(" %s", temp);
- } else {
- /** Trunc it.. **/
- strcpy(temp, d);
- temp[maxlength] ='\0';
- printw(" %s..", temp);
- }
+
+ if(strlen(d) <= maxlength)
+ printw("%s", d);
+ else { /** Trunc it.. **/
+ strcpy(temp, d);
+ temp[maxlength-2] ='\0';
+ printw("%s..", temp);
}
switch(type)
@@ -362,17 +354,17 @@ Display_Dir_Page(GopherDirObj *gopherdir,
boolean dogplus = FALSE;
GopherObj *gs;
static char *MenuStyle = NULL;
- static int MenuBytePad;
int j;
+ /* Hide the cursor */
+ curs_set(0);
/*** Clear the screen and redraw the top line **/
clear();
Draw_Banner();
if (MenuStyle == NULL) {
if ((MenuStyle = getenv("GOPHERMENUSTYLE")) == NULL)
- MenuStyle = "[%d]";
- MenuBytePad = strlen(MenuStyle)-2;
+ MenuStyle = " %6d "; /* up to 6 index digits (999999)*/
}
@@ -386,24 +378,17 @@ Display_Dir_Page(GopherDirObj *gopherdir,
for (i= 0, iOffset = (nNewPage-1) * iPageLen; i <iLoop; i++, iOffset++) {
gs = GDgetEntry(gopherdir, iOffset);
- move(MENULINE(i+1), 6);
+ move(MENULINE(i+1), 0);
if (GSgetType(gs) == A_INFO) {
- for (j=0; j <= MenuBytePad; j++)
- addch(' ');
-
- if (iOffset >= 9)
- addch(' ');
- if (iOffset >= 99)
+ for (j=0; j < MenuMargin; j++)
addch(' ');
} else {
printw(MenuStyle, iOffset +1);
}
- if (iOffset + 1 < 10)
- addch(' ');
dogplus = GSisGplus(GDgetEntry(gopherdir, iOffset));
- DisplayTitle(GDgetEntry(gopherdir, iOffset), COLS-13, dogplus);
+ DisplayTitle(GDgetEntry(gopherdir, iOffset), COLS-MenuMargin, dogplus);
}
}
@@ -485,12 +470,12 @@ scline(int iOldGopher, int iNewGopher, GopherDirObj *gophersdir)
sprintf(sPagenum, Gtxt(" Page: %d/%d",56), nNewPage, nMaxPages);
Draw_Status(sPagenum);
- mvaddstr(MENULINE(iOldLine), 1, " ");
+ mvchgat(MENULINE(iOldLine), MenuMargin, MenuLineMax, A_NORMAL, 1, NULL);
if ( (GSgetType(GDgetEntry(gophersdir, iNewGopher-1)) == A_INFO) ||
(GSgetType(GDgetEntry(gophersdir, iNewGopher-1)) == A_ERROR) )
- mvaddstr(MENULINE(iNewLine), 1, "---");
+ mvaddstr(MENULINE(iNewLine), 1, "X");
else
- mvaddstr(MENULINE(iNewLine), 1, "-->");
+ mvchgat(MENULINE(iNewLine), MenuMargin, MenuLineMax, A_REVERSE, 1, NULL);
refresh();
return(iNewGopher);
--
2.46.1