[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: Tue, 23 Apr 2024 16:25:24 +0100
- To: user@xxxxxxxxxxxxxxxxxxxxxx
On Tue, 23 Apr 2024 at 00:41, Brian G <brian@xxxxxxxxxxxxxxxx> wrote: > > On 4/20/24 07:19, Bruce Steers wrote: > > It seems that line gets all the PS1 string > though > > My PS1 is this.. > '\[\e]0;\u: \W\a\]\[\033[01;96m\]\u\[\033[00m\]:\[\033[01;92m\]\W\[\033 > > between the \e]0; and the \a\] is the part that is read to set the title. > > The "title getting" code uses this PS1 string, > if i change my PS1 to say '\u \w : ' then the PS1 does not have the \e]0; > and the terminal will not fire a Title change anymore as it requires this > syntax. > > That PS1 variable is the exact string that sData in the OutputTo method > reads. > So i reckon it could be considered as much as a solid standard as the > title change is. > > It's a darn shame there is no reasonable / reliable method :( > > Respects > BruceS :) > > > On Sat, 20 Apr 2024 at 06:55, Benoît Minisini < > benoit.minisini@xxxxxxxxxxxxxxxx> wrote: > >> Le 20/04/2024 à 04:58, Bruce Steers a écrit : >> > >> > 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 >> < >> 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 >> > >> >> This code manages the command for setting the terminal emulator window >> title. It is an XTerm specific command that became implicit standard. >> >> Nothing says that the window title will include the prompt. >> >> Regards, >> >> -- >> Benoît Minisini. >> >> >> I am not sure if this helps, but there is a filter hook in the > terminal that allows to monitor what is written to the terminal. > Would it be possible to monitor that for the last output, or an expected prompt? > > The problem is the prompt cannot really be "expected" to be anything as any user or script can change it with the PS1 variable. The only way i can see to reliably get the bash prompt is to use this command.. echo ${PS1@P} I tried using something like this... TerminalView1.AlternateScreen = True TerminalView1.Input(" echo ${PS1@P} > /tmp/tvresult\n") TerminalView1.AlternateScreen = False While Not Exist("/tmp/tvresult") Wait 0.1 Wend Dim sResult as String = Trim(File.Load("/tmp/tvresult")) it just then needs the escape sequences removed. But it's ugly as the terminal flickers to the other screen, it'd be nice to be able to use the AlternateScreen invisibly. currently i'm just using the same method the Title event uses. VT100 monitors output for a string in the PS1 that has the title, but i discovered also has the prompt string. but if the user or the script changes the PS1 to a non standard format it will not work. the echo ${PS1@P} seems the best way. Respects BruceS
Re: TerminalView position and text of prompt | Brian G <brian@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> |
Re: TerminalView position and text of prompt | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: TerminalView position and text of prompt | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |
Re: TerminalView position and text of prompt | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: TerminalView position and text of prompt | Brian G <brian@xxxxxxxxxxxxxxxx> |