Q. TSE: Linux + Microsoft Windows: Error: 'menu too large - needed: 58 rows - 91 columns'

13 views
Skip to first unread message

knud van eeden

unread,
Jan 6, 2026, 7:58:46 PMJan 6
to SemWare TSE Pro Text Editor, S.E. Mitchell
 Q. TSE: Error: 'menu too large - needed: 58 rows - 91 columns'

To work towards finally (reported since at least 2008 and earlier) 
resolving this very common error
in both TSE for Linux and TSE for Microsoft Windows
to start with here a simplest scrolling TSE program
(it works in TSE in both Microsoft Windows and Linux).

Then possibly working from there to implement something
similar if applicable for TSE Menu() native C source code.

---

 PROC Main()
  INTEGER quit = FALSE
  INTEGER start = 1    // Start of the 3-digit window
  INTEGER minI = 1     // Minimum start value
  INTEGER maxI = 7     // Maximum start value (so we can show 7,8,9)
  //
  Warn("Use Left/Right arrows to scroll groups. Press Q to quit.")
  //
  REPEAT
   // Display current 3-digit group
   Message("Current group: ", start, " ", start+1, " ", start+2)
   //
   // Get key and handle it
   CASE GetKey()
    WHEN <CursorLeft>
     IF start > minI
      start = start - 1
     ENDIF
    WHEN <CursorRight>
     IF start < maxI
      start = start + 1
     ENDIF
    WHEN <Q>, <q>
     quit = TRUE
   ENDCASE
   //
  UNTIL quit
 END

with friendly greetings
Knud van Eeden

knud van eeden

unread,
Jan 7, 2026, 5:38:01 PMJan 7
to SemWare TSE Pro Text Editor, S.E. Mitchell
In this more advanced version the menu options are printed vertically.

These menu options will also follow dynamically the changed current TSE vertical window size
(as given by Query( ScreenRows ) ).

It works in TSE for Linux and TSE for Microsoft Windows.

===

// tsemenuscroll.s - TSE SAL vertical scrolling menu demonstration
// Version 1.5 - 2025-01-07
//
PROC Main()
 INTEGER quitB = FALSE
 INTEGER startI = 1 // startI of the visible window
 INTEGER minI = 1 // Minimum startI value
 INTEGER maxI = 0 // Maximum startI value
 INTEGER windowSizeI = Query(ScreenRows) - 3 // Number of items to display
 INTEGER totalItemsI = 0 // Total number of items
 INTEGER cursorI = 1 // Current cursorI position within window (1-based)
 INTEGER selectedI = 0 // selected value (0 = none selected)
 INTEGER I = 0
 totalItemsI = 100 // change this, it is the total number of menu items
 //
 Warn("Use Up/Down/PgUp/PgDn arrows to scroll. Press <Enter> to select, Q to quit.")
 //
 REPEAT
  // Recalculate window size dynamically
  windowSizeI = Query(ScreenRows) - 3
  //
  // Adjust cursor position if window shrunk
  IF cursorI > windowSizeI
   cursorI = windowSizeI
  ENDIF
  //
  // Calculate based on current screen size
  maxI = totalItemsI - windowSizeI + 1
  IF maxI < minI
   maxI = minI
  ENDIF
  //
  // Adjust start position if needed
  IF startI > maxI
   startI = maxI
  ENDIF
  //
  // Clear and display current group vertically
  VGotoXY( 1, 1 )
  FOR I = 0 to windowSizeI - 1
   VGotoXY( 1, I + 1 )
   // Highlight the cursor position
   IF I + 1 == cursorI
    Set( Attr, Color( bright yellow on red ) ) // Highlighted
   ELSE
    Set( Attr, Color( bright white on blue ) ) // Normal
   ENDIF
   PutStr( Format( startI + i:3 ) ) // Right-aligned in a 3 character width
  ENDFOR
  //
  // Get key and handle it
  CASE GetKey()
   //
   WHEN <CursorUp>, <WheelUp>
    IF cursorI > 1
     cursorI = cursorI - 1
    ELSEIF startI > minI
     startI = startI - 1
    ENDIF
   //
   WHEN <CursorDown>, <WheelDown>
    IF cursorI < windowSizeI
     cursorI = cursorI + 1
    ELSEIF startI < maxI
     startI = startI + 1
    ENDIF
   //
   WHEN <PgUp>
    startI = startI - windowSizeI
    IF startI < minI
     startI = minI
    ENDIF
   //
   WHEN <PgDn>
    startI = startI + windowSizeI
    IF startI > maxI
     startI = maxI
    ENDIF
   //
   WHEN <Enter>
    selectedI = startI + cursorI - 1
    Message( "Selected value: ", selectedI )
    quitB = TRUE
   //
   WHEN <Q>, <q>
    quitB = TRUE
   //
  ENDCASE
  //
 UNTIL quitB
 //
 // Clean up display
 UpdateDisplay(_ALL_WINDOWS_REFRESH_)
 //
 // Show final result if something was selected
 IF ( selectedI > 0 )
  Warn( "You selected: ", selectedI )
 ENDIF
 //
END

===

Inline image
Inline image




knud van eeden

unread,
Jan 7, 2026, 6:03:59 PMJan 7
to SemWare TSE Pro Text Editor, S.E. Mitchell
Here a Borland C version.

You must run it in Windows Terminal (=wt.exe).

It will not work in tcc.exe or cmd.exe.

compile it with

 bcc tsemenuscrollborland.c

===

/* tsemenuscrollborland.c - Vertical scrolling menu demonstration
 * Version 1.9 - 2025-01-07
 * Compile with: bcc tsemenuscrollborland.c
 */

#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <string.h>

#define TRUE 1
#define FALSE 0
#define ENTER 13
#define ESC 27
#define ARROW_PREFIX 0
#define UP_ARROW 72
#define DOWN_ARROW 80
#define PGUP 73
#define PGDN 81

int getScreenRows(void) {
    struct text_info ti;
    gettextinfo(&ti);
    return ti.screenheight;
}

int main(void) {
    int quitB = FALSE;
    int startI = 1;
    int minI = 1;
    int maxI = 0;
    int windowSizeI;
    int totalItemsI = 100;  /* change this - total number of menu items */
    int cursorI = 1;
    int selectedI = 0;
    int i;
    int key;
    int topRow = 1;  /* Fixed top row for menu */
    
    /* Initial screen setup */
    _setcursortype(_NOCURSOR);  /* Hide cursor */
    clrscr();
    
    do {
        /* Recalculate window size dynamically */
        windowSizeI = getScreenRows();
        
        /* Adjust cursor position if window shrunk */
        if (cursorI > windowSizeI) {
            cursorI = windowSizeI;
        }
        
        /* Calculate based on current screen size */
        maxI = totalItemsI - windowSizeI + 1;
        if (maxI < minI) {
            maxI = minI;
        }
        
        /* Adjust start position if needed */
        if (startI > maxI) {
            startI = maxI;
        }
        
        /* Redraw entire menu at fixed position */
        for (i = 0; i < windowSizeI; i++) {
            gotoxy(1, topRow + i);
            
            /* Highlight the cursor position */
            if (i + 1 == cursorI) {
                textbackground(RED);
                textcolor(YELLOW);
            } else {
                textbackground(BLUE);
                textcolor(WHITE);
            }
            
            /* Print the number with padding to clear the line */
            cprintf(" %3d%-74s", startI + i, "");
        }
        
        /* Get key and handle it */
        key = getch();
        
        /* Handle extended keys (arrows, function keys) */
        if (key == ARROW_PREFIX || key == 224) {
            key = getch();
            
            switch (key) {
                case UP_ARROW:
                    /* Same logic as TSE SAL version */
                    if (cursorI > 1) {
                        cursorI = cursorI - 1;
                    } else if (startI > minI) {
                        startI = startI - 1;
                    }
                    break;
                    
                case DOWN_ARROW:
                    /* Same logic as TSE SAL version */
                    if (cursorI < windowSizeI) {
                        cursorI = cursorI + 1;
                    } else if (startI < maxI) {
                        startI = startI + 1;
                    }
                    break;
                    
                case PGUP:
                    startI = startI - windowSizeI;
                    if (startI < minI) {
                        startI = minI;
                    }
                    break;
                    
                case PGDN:
                    startI = startI + windowSizeI;
                    if (startI > maxI) {
                        startI = maxI;
                    }
                    break;
            }
        } else {
            /* Handle regular keys */
            switch (key) {
                case ENTER:
                    selectedI = startI + cursorI - 1;
                    quitB = TRUE;
                    break;
                    
                case 'q':
                case 'Q':
                    quitB = TRUE;
                    break;
            }
        }
        
    } while (!quitB);
    
    /* Clean up display */
    _setcursortype(_NORMALCURSOR);  /* Restore cursor */
    textbackground(BLACK);
    textcolor(LIGHTGRAY);
    clrscr();
    
    /* Show final result if something was selected */
    if (selectedI > 0) {
        printf("You selected: %d\n", selectedI);
    }
    
    return 0;
}


===

Inline image


===

knud van eeden

unread,
Jan 7, 2026, 6:09:48 PMJan 7
to SemWare TSE Pro Text Editor, S.E. Mitchell
Here a Watson C version for usage on Linux:

Here is a Linux version that uses ncurses for Watson C:

Note: not compiled here.

===

To compile with Watcom C on Linux

wcc386 tsemenuscrollwatson.c -l=ncurses
wcl386 tsemenuscrollwatson.o -l=ncurses
===

Or with gcc (more common on Linux):
gcc tsemenuscrollwatson.c -o tsemenuscrollwatson -lncurses

Key differences from the Borland version:

  • Uses ncurses library instead of conio.h
  • initscr() to initialize ncurses mode
  • keypad(stdscr, TRUE) to enable arrow key detection
  • KEY_UP, KEY_DOWN, KEY_PPAGE, KEY_NPAGE for arrow and page keys
  • COLOR_PAIR() for color management
  • refresh() to update the display
  • endwin() to restore terminal on exit
  • Cross-platform (works on any Linux/Unix system with ncurses)
===

/* tsemenuscrollwatson.c - Vertical scrolling menu demonstration for Linux
 * Version 1.0 - 2025-01-07
 * Compile with: wcc386 tsemenuscrollwatson.c -l=ncurses
 * Or with gcc: gcc tsemenuscrollwatson.c -o tsemenuscrollwatson -lncurses
 */

#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>

#define TRUE 1
#define FALSE 0

int main(void) {
    int quitB = FALSE;
    int startI = 1;
    int minI = 1;
    int maxI = 0;
    int windowSizeI;
    int totalItemsI = 100;  /* change this - total number of menu items */
    int cursorI = 1;
    int selectedI = 0;
    int i;
    int key;
    int screenRows, screenCols;
    
    /* Initialize ncurses */
    initscr();
    cbreak();
    noecho();
    keypad(stdscr, TRUE);
    curs_set(0);  /* Hide cursor */
    
    /* Check if terminal supports colors */
    if (has_colors()) {
        start_color();
        init_pair(1, COLOR_WHITE, COLOR_BLUE);    /* Normal */
        init_pair(2, COLOR_YELLOW, COLOR_RED);    /* Highlighted */
    }
    
    /* Display instructions */
    clear();
    mvprintw(0, 0, "Use Up/Down/PgUp/PgDn arrows to scroll. Press Enter to select, Q to quit.");
    mvprintw(1, 0, "Press any key to continue...");
    refresh();
    getch();
    
    do {
        /* Get screen dimensions */
        getmaxyx(stdscr, screenRows, screenCols);
        windowSizeI = screenRows - 3;
        
        /* Adjust cursor position if window shrunk */
        if (cursorI > windowSizeI) {
            cursorI = windowSizeI;
        }
        
        /* Calculate based on current screen size */
        maxI = totalItemsI - windowSizeI + 1;
        if (maxI < minI) {
            maxI = minI;
        }
        
        /* Adjust start position if needed */
        if (startI > maxI) {
            startI = maxI;
        }
        
        /* Clear and display current group vertically */
        for (i = 0; i < windowSizeI; i++) {
            move(i, 0);
            
            /* Highlight the cursor position */
            if (i + 1 == cursorI) {
                if (has_colors()) {
                    attron(COLOR_PAIR(2));
                }
                attron(A_BOLD);
            } else {
                if (has_colors()) {
                    attron(COLOR_PAIR(1));
                }
            }
            
            /* Print the number with padding */
            printw(" %3d", startI + i);
            clrtoeol();  /* Clear to end of line */
            
            /* Turn off attributes */
            if (has_colors()) {
                attroff(COLOR_PAIR(1));
                attroff(COLOR_PAIR(2));
            }
            attroff(A_BOLD);
        }
        
        refresh();
        
        /* Get key and handle it */
        key = getch();
        
        switch (key) {
            case KEY_UP:
                /* Same logic as TSE SAL version */
                if (cursorI > 1) {
                    cursorI = cursorI - 1;
                } else if (startI > minI) {
                    startI = startI - 1;
                }
                break;
                
            case KEY_DOWN:
                /* Same logic as TSE SAL version */
                if (cursorI < windowSizeI) {
                    cursorI = cursorI + 1;
                } else if (startI < maxI) {
                    startI = startI + 1;
                }
                break;
                
            case KEY_PPAGE:  /* Page Up */
                startI = startI - windowSizeI;
                if (startI < minI) {
                    startI = minI;
                }
                break;
                
            case KEY_NPAGE:  /* Page Down */
                startI = startI + windowSizeI;
                if (startI > maxI) {
                    startI = maxI;
                }
                break;
                
            case 10:  /* Enter key */
            case KEY_ENTER:
                selectedI = startI + cursorI - 1;
                quitB = TRUE;
                break;
                
            case 'q':
            case 'Q':
                quitB = TRUE;
                break;
        }
        
    } while (!quitB);
    
    /* Clean up ncurses */
    endwin();
    
    /* Show final result if something was selected */
    if (selectedI > 0) {
        printf("You selected: %d\n", selectedI);
    }
    
    return 0;
}

===
Reply all
Reply to author
Forward
0 new messages