[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TerminalView position and text of prompt
[Thread Prev] | [Thread Next]
- Subject: Re: TerminalView position and text of prompt
- From: Bruce Steers <bsteers4@xxxxxxxxx>
- Date: Sat, 20 Apr 2024 03:58:55 +0100
- To: user@xxxxxxxxxxxxxxxxxxxxxx
On Tue, 16 Apr 2024 at 14:15, Benoît Minisini < benoit.minisini@xxxxxxxxxxxxxxxx> wrote: > Le 16/04/2024 à 15:03, Bruce Steers a écrit : > > > > So i just need to know reliably where exactly the PS1 prompt ends and > > the command begins. > > > > If possible, If somewhere in the terminalview code this place is known? > > Or if from the codes perspective that position is all handled by the > > running shell so it's irrelevant/unknown. > > > > Respects > > BruceS > > > > I think there is no reliable way to detect a prompt: > > - The shell knows what the prompt is, and when it will be printed to the > terminal. But it cannot know how exactly it will be drawn inside the > terminal. > > - The terminal knows how things are drawn. But it has no way to know > what is a prompt, and what is not a prompt. > > Regards, > > -- > Benoît Minisini. > I may have found an answer already in the code... https://gitlab.com/gambas/gambas/-/blob/master/comp/src/gb.form.terminal/.src/TerminalView/TerminalFilter_VT100.class?ref_type=heads#L158 it does this..... If sCmd = "0" Or If sCmd = "2" Then hView.Title = sTitle sData at that point has the path to the left of iPos2 that is used to set the title and it seems to have the prompt to the right If sCmd = "0" Or If sCmd = "2" Then hView.Title = sTitle hView.Prompt = Mid$(sData, iPos2 + 1) I wish there was an easily way to remove escape sequences and convert it to plain text All i found was a sed command Private Sub Prompt_Write(Value As String) Shell "echo -n '" & Value & "'| sed -r \"s/\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g\"" To $sPrompt End Respects BruceS
Re: TerminalView position and text of prompt | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |
TerminalView position and text of prompt | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: TerminalView position and text of prompt | Gianluigi <gradobag@xxxxxxxxxxx> |
Re: TerminalView position and text of prompt | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: TerminalView position and text of prompt | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |