Cut and Paste in Terminal
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Cut and Paste in Terminal
Can anyone point me in the right direction. I am trying to Cut and Paste in a Gambas Terminal. I have attached a small program to help highlight the issue. I would like to be able to Copy selected text from Terminal and Paste text into Terminal. I can Copy but only ALL the text, no need to highlight.
Re: Cut and Paste in Terminal
Hello Cogier
Maybe using the "Clipboard" function...
Type "cli"... then a popup should open in the help...
Have a nice day.
Maybe using the "Clipboard" function...
Type "cli"... then a popup should open in the help...
Have a nice day.
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Cut and Paste in Terminal
Thanks Didier but I still can't get it to work. I have even loaded the Gambas daily build on a computer hoping that the 'help' for TerminalView had been updated, but no!
Re: Cut and Paste in Terminal
Hello Cogier
Yes, I misunderstood your question.
In fact you would like to retrieve what is highlighted in the end part (and only this?).
Maybe a start to the track...
When you type 1 command, it starts with "#" and each answer is separated by "\n".
When you type 2 commands, they are separated by a "#" and the internal answers are also separated by a "\n".
All of this is visible in the text property.
Maybe a split might be suitable for temporary use?
Here is an example when I type probepart and probedisk commands.
Of course it is easier for me to type these commands in "shell" and get the result in a variable...
It all depends on what you want to do...
Have a nice day.
Yes, I misunderstood your question.
In fact you would like to retrieve what is highlighted in the end part (and only this?).
Maybe a start to the track...
When you type 1 command, it starts with "#" and each answer is separated by "\n".
When you type 2 commands, they are separated by a "#" and the internal answers are also separated by a "\n".
All of this is visible in the text property.
Maybe a split might be suitable for temporary use?
Here is an example when I type probepart and probedisk commands.
Of course it is easier for me to type these commands in "shell" and get the result in a variable...
It all depends on what you want to do...
Code: Select all
"# probepart\n/dev/sda1|ext3|109373440\n/dev/sda5|swap|7852032\n# probedisk\n/dev/sda|drive|ATA ST96812AS \n/dev/sr0|optical|TSSTcorpDVD+-RW \nTS-U633F\n# "
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Cut and Paste in Terminal
I have tried looking for the '\n' (gb.newline) but it is not put in the text so does not show up in a string.
Re: Cut and Paste in Terminal
Hello cogier
In the "Public Sub TerminalMenu_Click ()",
you have to declare "sline" and she's the one who will retrieve the contents of "TerminalView1. Text"
Or look in the console...
Have a nice day.
In the "Public Sub TerminalMenu_Click ()",
you have to declare "sline" and she's the one who will retrieve the contents of "TerminalView1. Text"
Public Sub TerminalMenu_Click()
Dim sline As String
sline = TerminalView1.Text
Print sline
Wait
' Select Case Last.Name
' Case "MenuPaste"
' 'TerminalView1.Input = Clipboard.Paste
' Case "MenuCopy"
' Clipboard.Copy(TerminalView1.Text) ''Copys ALL the text in Terminal without the need to highlight?
' End Select
End
Set a stop point on the "wait" to analyze the content "sline".Or look in the console...
Have a nice day.
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Cut and Paste in Terminal
With the help of my friend Matt we found that the 'TerminalView.copy' works fine but we could not get the 'TerminalView.paste' to work. So with the help of 'Desktop.sendkeys' we came up with the following code for the 'Terminal_Copy_Paste' program in my first post.
Thanks for all the input.
Thanks for all the input.
pBash As Process
sCopy As String
Public Sub Form_Show()
pBash = TerminalView1.Exec(["bash"])
TerminalView1.SetFocus
End
Public Sub ButtonClear_Click()
TextArea1.Clear
TerminalView1.SetFocus
End
Public Sub Form_Close()
pBash.close
End
Public Sub TerminalMenu_Click()
Dim sTemp As String
TerminalView1.setfocus
Select Case Last.Name
Case "MenuPaste"
sTemp = Clipboard.Paste("text/plain")
SendTheKeys(sTemp)
Case "MenuCopy"
TerminalView1.Copy
End Select
End
Public Sub SendTheKeys(sText As String)
Dim siCount As Short
For siCount = 1 To Len(sText)
If Mid(sText, siCount, 1) = "[" Then
Desktop.SendKeys("[bracketleft]")
Else
Desktop.SendKeys(Mid(sText, siCount, 1))
Endif
Next
End
Re: Cut and Paste in Terminal
Hello cogier
Simple and effective solution.
Thank you and congratulations to you both.
Have a nice day.
Simple and effective solution.
Thank you and congratulations to you both.
Have a nice day.
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Cut and Paste in Terminal
The attached program was what it was all about. I would appreciate any feed back as I know you good people use different Distros.