Hello
My first probleme was to find how to close a Console window without terminating the whole program. As I found out that it was impossible, is there a way to mimic a console behaviour inside an EditorGagdet, which means that the user can only enter input at the last cursor position and an output is generated when user hits "Enter" .
any other solution is welcome
Thanks
Mimic command line behaviour in an EditorGadget()
-
Randy Walker
- Addict

- Posts: 1109
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
Re: Mimic command line behaviour in an EditorGadget()
Try this in v6.11 or above, Windows Only!!. (don't know about others) I don't think you can type anywhere except end of the text.
[HINT] do web search for "EM_SETSEL" to learn about cursor placement and text selections.
Code: Select all
#KB_Return = #PB_Shortcut_Return + 49152
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 8, 8, 306, 133)
For a = 0 To 5
AddGadgetItem(0, a, "Line "+Str(a))
Next
AddKeyboardShortcut(0, #PB_Shortcut_Return, #KB_Return)
SetActiveGadget(0) ; necessary to get cursor active in edit box.
Repeat
SendMessage_(GadgetID(0),#EM_SETSEL,-1,-1) ; Force cursor to End of text.
Select EventMenu()
Case #KB_Return ; Catch Return Key
s$ = GetGadgetText(0) ;get input if return key
Break ; exit the loop with all text in s$
EndSelect
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Debug s$
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
Re: Mimic command line behaviour in an EditorGadget()
Did you ask a similar question back in February?
Simulate Terminal in an EditorGadget
Does the RASHAD example not work?
Perhaps this is something for you?
Module: TerminalGadget
Simulate Terminal in an EditorGadget
Does the RASHAD example not work?
Perhaps this is something for you?
Module: TerminalGadget
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
-
Randy Walker
- Addict

- Posts: 1109
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
Re: Mimic command line behaviour in an EditorGadget()
I didn't ask the question. I ran into this coding question post and noticed it had no reply so I replied.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
Re: Mimic command line behaviour in an EditorGadget()
Looks like the OP made two topics about this issue, this one that never got any replies until recently, and the one linked a couple posts back.Randy Walker wrote: Fri Sep 13, 2024 5:41 pmI didn't ask the question. I ran into this coding question post and noticed it had no reply so I replied.
Re: Mimic command line behaviour in an EditorGadget()
Yeah, Quin is right.

I (never) look at the date. So, Randy, if you felt offended. Here's my apology. Because that was not my intention.Quin wrote: Fri Sep 13, 2024 11:04 pm Randy Walker wrote: ↑13 Sep 2024, 18:41
Axolotl wrote: ↑13 Sep 2024, 14:20
Did you ask a similar question back in February?
I didn't ask the question. I ran into this coding question post and noticed it had no reply so I replied.
Looks like the OP made two topics about this issue, this one that never got any replies until recently, and the one linked a couple posts back.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
-
Randy Walker
- Addict

- Posts: 1109
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
Re: Mimic command line behaviour in an EditorGadget()
Axolotl wrote: Sun Sep 15, 2024 1:30 pm Yeah, Quin is right.
I (never) look at the date. So, Randy, if you felt offended. Here's my apology. Because that was not my intention.![]()
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
