Console clear to end of line

Just starting out? Need help? Post your questions and find answers here.
Oso
Enthusiast
Enthusiast
Posts: 595
Joined: Wed Jul 20, 2022 10:09 am

Re: Console clear to end of line

Post by Oso »

HeX0R wrote: Thu Jan 26, 2023 11:40 pm You could also use this here and add a few things to your needs: viewtopic.php?f=12&t=64556 Then it would be even cross platform.
I think this is the way to go, agreed. You have control over the functions, rather than fighting to work around the limitations with the Windows console. It's a little bit laggy to display, resize and move the scroll bar on my development system, but that's because my system is deliberately slow (I prefer testing and development on low-spec hardware). I do all my work through an RDP session to a Windows 10 VirtualBox guest inside a Linux server and it's a little slow to update the screen for some operations. :? Redrawing windows is slow, but strangely, scrolling text is very fast.

The other way that springs to mind, with consoles, is the below very simple illustration which I'd saved from some weeks ago and I think was courtesy of Olli, although I can't find Olli's post now. This makes use of PB gadgets. It doesn't have the advantage that yours has, in that yours allows you to address a specific position in the console window, therefore you can intermix your commands and your output results. In the PB gadgets, you're limited to a display window and a command input, which although kind of modern looking, doesn't have the similicity of the old style consoles. It does have a performance advantage though.

Code: Select all

win = OpenWindow(#PB_Any, 0,0, 800, 400, "Command console", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
w = WindowWidth(win)
h = WindowHeight(win) - 70

gd = EditorGadget(#PB_Any, 0,0, w,h)
fnt = LoadFont(#PB_Any, "courier new", 10, #PB_Font_Bold)

SetGadgetFont(gd, FontID(fnt) )
SetGadgetColor(gd, #PB_Gadget_FrontColor, RGB(0,0,255) )
SetGadgetColor(gd, #PB_Gadget_BackColor, RGB(191, 191, 191) )
AddGadgetItem(gd, -1, "Results output area")

cmd.s = "Enter your command here, then click Run"

ButtonGadget(#PB_Any,w-75,340,50,50,"Run",#Null)
EditorGadget(#PB_Any,3,330,w-100,70,#Null)

SetActiveGadget(gd)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Post Reply