×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Creating a terminal menu with scrollable text

Creating a terminal menu with scrollable text

Creating a terminal menu with scrollable text

(OP)
I am using a terminal only so no GUI and using Free Pascal 2.6.2. If I have a screen that begins on line 5 I can use the arrow keys to move down to say line 26, and if I get to line 27 it goes back to line 5, and line 4 wraps to line 25. All good and works with enter if a line is selected.

My problem is, if I have text that is say 100 lines long, I want to keep using the arrow keys go down, and if at line 27, line 27 moves to line 26 and line 26 to line 25 and line 5 would be removed from view.

Does anyone have an example of how to accomplish this?

RE: Creating a terminal menu with scrollable text

Isn't it dependent only of your terminal window settings ?
For examle in Windows you can set Screen Buffer Size, which means how many lines has your command scrren.
See this for example: http://delltech.150m.com/XP/dos/4.htm

RE: Creating a terminal menu with scrollable text

I pulled out an old text viewer project in Turbo Pascal which was rather interesting to see still works in Windows 8. Anyhow, there's a lot there, but here's a clue on how I handled it (too much here to repost the whole thing):

CODE

{ header changed along with corresponding calls }
  procedure processdown(textarray: array of Pchar; textstring: string;
               var beginline: integer; var endline: integer;
               totallines: integer);
    begin
      if endline < totallines then
        begin
          gotoxy(1,2);
          delline;
          beginline := beginline + 1;
          endline := endline + 1;
          gotoxy(1,25);
          write(textarray[endline]);
          redrawtop(textstring);
        end;
    end;

{ header changed along with all corresponding calls }
  procedure processup(textarray: array of Pchar; textstring: string;
             var beginline: integer; var endline: integer);
    begin
      if beginline <> 0 then
        begin
          gotoxy(1,2);
          insline;
          beginline := beginline - 1;
          endline := endline - 1;
          write(textarray[beginline]);
          redrawtop(textstring);
        end;
    end; 
This is what gets called when the user presses the DOWN or UP key. RedrawTop() is just a procedure that puts a status line on the top of the screen that says "Viewing <XYZ>, Press F1 for Help", nothing relevant to what your question is. Textarray is the place where the text lines are stored in memory.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close