Forum > LCL

What control to use to mimic a console window?

(1/3) > >>

new2thisagain395:
I'm writing an app that (currently) just writes to the console (using writeln etc.) and accepts user input by monitoring keystrokes.  Works fine.

But if I want to do this within a windowed Lazarus application (essentially an endlessly-scrolling window like a video terminal), what control do I use?  I've been reading through all of the controls descriptions and can't find one that appears to do what I want.

TRon:

--- Quote from: new2thisagain395 on March 24, 2024, 12:46:11 am ---But if I want to do this within a windowed Lazarus application (essentially an endlessly-scrolling window like a video terminal), what control do I use?  I've been reading through all of the controls descriptions and can't find one that appears to do what I want.

--- End quote ---
TMemo is able to do that for you. You can reroute the output error channels to add the output to the strings property. Use the background to set another background and a fixed (mono) font.

cdbc:
Hi
edit: TRon beat me to it  :D
Use a 'TMemo' and do this:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---...{when the /screen/ gets to aLineCount lines, it starts scrolling, default is 24}procedure AddStrToMemoScroll(const aStr: string; aLineCOunt: integer = 24);begin  if Memo1.Lines.Count >= aLineCOunt then Memo1.Lines.Delete(0);  Memo1.Lines.add(aStr);end;... it will mimic a scrolling console
Regards Benny

Leledumbo:
https://wiki.lazarus.freepascal.org/CmdLine, install from OPM, wiki is outdated.

new2thisagain395:
So, I've been working on this for a few hours, migrating from a console program to a simple window program using a TMemo control.  I'm getting there.

To prevent what would be considered normal functionality in this TMemo control (such as the ability to highlight text, edit, move the cursor up and down, etc.), which I don't want any of, how do I disable all of that?  Do I need to set event handlers for certain user-driven functions such as noted above and don't have them call the base event handler code?  Or is there an easier way?   Thanks.

Edit: I'm still not sure if this is the best approach to take (using this control).  The way this application works is, there's a series of cascaded menus that the user makes single-keystroke selections from.   After 2, 3, or 4 (usually) of these selections they have to enter in some text and hit Return.  It does what was requested and restarts at the topmost menu.  Something similar to this:


--- Code: ---$Run, Load, Set, Display, Transfer, scheduLe, Bye?  S
$Value, Definition, History, Quit?  V

Item:  ABCOBJECT (CR)
Value: 65 (CR)

Ok

$Run, Load, Set, Display, Transfer, scheduLe, Bye?


--- End code ---

So I know I can use the KeyPressed event to capture keypresses, but then (since the event handler doesn't have any idea where in this menu tree the user is at) I'd have to set status values or use some other method of identifying every unique 'location' in the menuing tree where the user is.  Etc.

Hope that explanation makes sense.  If there was a different control that worked more like the non-GUI console that'd probably be better.

Navigation

[0] Message Index

[#] Next page

Go to full version