Cut and Paste in Terminal

Post

Posted
Rating:
#1 (In Topic #146)
Avatar
Guru
cogier is in the usergroup ‘Guru’
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. :cry:
Attachment
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
didier18 is in the usergroup ‘Regular’
 Hello Cogier

Maybe using the "Clipboard" function…
Type "cli"… then a popup should open in the help…

Have a nice day.

Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
 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!
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
didier18 is in the usergroup ‘Regular’
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…

Code

"# 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# "
Have a nice day.

Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
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. :(
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
didier18 is in the usergroup ‘Regular’
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"

Code (gambas)

  1. Public Sub TerminalMenu_Click()
  2. Dim sline As String
  3.  
  4.   sline = TerminalView1.Text
  5.  
  6.   Print sline
  7.   Wait
  8.      
  9. ' Select Case Last.Name
  10. '   Case "MenuPaste"
  11. '     'TerminalView1.Input = Clipboard.Paste
  12. '   Case "MenuCopy"
  13. '     Clipboard.Copy(TerminalView1.Text) ''Copys ALL the text in Terminal without the need to highlight?
  14. ' End Select
Set a stop point on the "wait" to analyze the content "sline".
Or look in the console…

Have a nice day.

Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Regular
jornmo is in the usergroup ‘Regular’
She :roll:  :D

Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.

Code (gambas)

  1. pBash As Process
  2. sCopy As String
  3.  
  4. Public Sub Form_Show()
  5.  
  6. pBash = TerminalView1.Exec(["bash"])
  7. TerminalView1.SetFocus
  8.  
  9.  
  10. Public Sub ButtonClear_Click()
  11.  
  12. TextArea1.Clear
  13. TerminalView1.SetFocus
  14.  
  15.  
  16. Public Sub Form_Close()
  17.  
  18. pBash.close
  19.  
  20.  
  21. Public Sub TerminalMenu_Click()
  22. Dim sTemp As String
  23.  
  24. TerminalView1.setfocus
  25.   Case "MenuPaste"
  26.     sTemp = Clipboard.Paste("text/plain")
  27.     SendTheKeys(sTemp)
  28.   Case "MenuCopy"
  29.     TerminalView1.Copy
  30.  
  31. Public Sub SendTheKeys(sText As String)
  32. Dim siCount As Short
  33.  
  34. For siCount = 1 To Len(sText)
  35.   If Mid(sText, siCount, 1) = "[" Then
  36.     Desktop.SendKeys("[bracketleft]")
  37.   Else
  38.     Desktop.SendKeys(Mid(sText, siCount, 1))
  39.  
Online now: No Back to the top

Post

Posted
Rating:
#9
Regular
didier18 is in the usergroup ‘Regular’
 Hello cogier

Simple and effective solution.
Thank you and congratulations to you both.

Have a nice day.

Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Guru
cogier is in the usergroup ‘Guru’
The attached program was what it was all about. I would appreciate any feed back as I know you good people use different Distros.

Attachment

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#11
Regular
didier18 is in the usergroup ‘Regular’
Hello Cogier

I just tried EasyTerminal 0.0.1.
As you know I work with distributions where the user is declared root (tooppy, tahr, tritone etc.).
So commands like "sudo" doesn't exist and the working / backup directory is root which is normally inaccessible under distributions like mint, debian etc..
During the 1st launch of EasyTerminal, there is an error on line 44. "The file or directory does not exist".
It's actually ". bash_history".
So I created an empty file in root that I named. bash_history then restarted EasyTerminal.
There, the browser (chromium) opened more than 50 tabs most of them on various empty pages or pointing to dead links and some to "man pages" and all in English (while there are "man pages" in French).
Finally EasyTerminal seems to be stuck at the line

362 File. Save (sFolder &/ LCase (sChar) & ". csv", sSpeedSave. Join (gb. newline))

with the message "The directory or file does not exist". A. csv file seems to be missing. I didn't go any further in my investigations.
Is there a specific name to give to the. csv file?

Have a nice day.

Translated with www.DeepL.com/Translator

Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Guru
cogier is in the usergroup ‘Guru’
 Hi Didier,

Thanks for trying the program. I think most Distributions have a Home folder and run in a protected mode and not in root. I have tried in the past to load ToOpPy but I ran into all sorts of problems.

'sudo' should not have been a problem as I didn't use it. The program tries to make a folder in the Home folder, which I presume does not exist in your case, and store the list of commands for faster retrieval. The folder will contain a .csv file for each of the buttons '0.csv' and 'a.csv' to 'z.csv'.

'.bash_history' is the file that in Ubuntu, Mint, Debian etc. that stores the commands you use in Terminal. It would seem that ToOpPy does not use Bash as a Terminal.

Can you try the program in Mint, I know you have used Mint before.  

Salut Didier,

Merci d'avoir essayé le programme. Je pense que la plupart des distributions ont un dossier Home et s'exécutent en mode protégé et non pas en root. J'ai essayé dans le passé de charger ToOpPy mais j'ai rencontré toutes sortes de problèmes.

sudo "n'aurait pas dû être un problème car je ne l'ai pas utilisé. Le programme essaie de faire un dossier dans le dossier Home, qui n'existe pas dans votre cas, je présume, et stocke la liste des commandes pour une récupération plus rapide. Le dossier contiendra un fichier. csv pour chacun des boutons' 0. csv'et' a. csv' à' z. csv'.

. bash_history'est le fichier qui stocke dans Ubuntu, Mint, Debian, etc. les commandes que vous utilisez dans Terminal. Il semblerait que ToOpPy n'utilise pas Bash comme Terminal.

Pouvez-vous essayer le programme dans Mint, je sais que vous avez déjà utilisé Mint avant.
Online now: No Back to the top

Post

Posted
Rating:
#13
Regular
didier18 is in the usergroup ‘Regular’
—en—
Hello Cogier

I've just tried under mint, if the. Bash_History file is created automatically, the program still locks to line 362 with the same message as before. Another difference is that the tabs do not open in "firefox", but you can see the numbers increasing on the first button.

Since this is an external hard drive that I use for testing, it is possible that mint or gambas3_3.10.0 may fail…

What is the command to type in terminal to know the version of bash? I could try under tooppy to get the information back to you.

Indeed the French translation may interest other users of the site, I attach the original text.

Have a nice day.

Translated with www.DeepL.com/Translator

—fr—
Bonjour Cogier

Je viens d'essayer sous mint, si le fichier .Bash_History est bien créé automatiquement, le programme se bloque malgré tout à la ligne 362 avec le même message que précédemment. Autre différence, les onglets ne s'ouvrent pas dans "firefox", mais on peut voir les chiffres augmenter sur le premier bouton.

S'agissant d'un disque dur externe que j'utilise pour des essais, il est possible que mint ou gambas3_3.10.0 soient défaillant…

Quelle est la commande à taper en terminal pour connaitre la version de bash ? Je pourrait essayer sous tooppy pour te retourner l'information.

Effectivement la traduction Française peut intéresser d'autres utilisateurs du site, je joint le texte original.

Bonne journée.

Online now: No Back to the top

Post

Posted
Rating:
#14
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi Didier,

A good example of changing something and breaking it!!

Move line 54 'If Not Exist(sFolder) Then Mkdir sFolder' to line 43, just before 'Me.Show'

Salut Didier,

Un bon exemple de changement et de rupture!!

Déplacez la ligne 54'If Not Exist(sFolder) Then Mkdir sFolder' à la ligne 43, juste avant'Me. Show'.

Traduit avec www.DeepL.com/Translator
Online now: No Back to the top

Post

Posted
Rating:
#15
Regular
didier18 is in the usergroup ‘Regular’
—en—
Hello Cogier

Ok after line reversal, easyterminal works.
One regret, the man pages are all in English, is there a way to select only French pages?
Is there a French translation of easyterminal (otherwise I can try to do it)?
How to add commands that do not exist under mint but are found under the different puppy's, such as probedisk and probepart?

Have a nice day.

Translated with www.DeepL.com/Translator

—fr—
Bonjour Cogier

Ok après l'inversion de ligne, easyterminal fonctionne.
- Un regret, les man pages sont toutes en Anglais, y a-t-il un moyen pour ne sélectionner que les pages Française de préférence ?
- Est-il prévu une traduction Française de easyterminal (sinon je peux essayer de le faire) ?
- Comment ajouter des commandes qui n'existe pas sous mint mais que l'on trouve sous les différentes puppy's, comme par exemple probedisk et probepart ?

Bonne journée.

Image

(Click to enlarge)


Online now: No Back to the top

Post

Posted
Rating:
#16
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi Didier,

Thanks for the feedback: -
One regret, the man pages are all in English, is there a way to select only French pages?
In Mint

Code

sudo apt-get install manpages-fr manpages-fr-extra
Is there a French translation of easyterminal (otherwise I can try to do it)?
Let me get some bugs sorted and then I will ask for your help.
How to add commands that do not exist under mint but are found under the different puppy's, such as probedisk and probepart?
It seems that these two commands are unique to Puppy Linux. I can't find what they do but I expect that there are other commands in Mint that will do a similar job.

Salut Didier,

Merci pour le feedback: -
Un regret, les pages de manuel sont toutes en anglais, y a-t-il un moyen de ne sélectionner que des pages en français?
Dans Mint

Code

sudo apt-get install manpages-fr manpages-fr
Est-ce qu'il y a une traduction française de easyterminal (sinon je peux essayer de le faire)?
Laissez-moi régler quelques bugs et je vous demanderai votre aide.
Comment ajouter des commandes qui n'existent pas sous menthe mais qui se trouvent sous les différents chiots, comme probedisk et probepart?
Il semble que ces deux commandes sont uniques à Puppy Linux. Je ne peux pas trouver ce qu'ils font, mais je m'attends à ce qu'il y ait d'autres commandes dans Mint qui feront un travail similaire.

Traduit avec www.DeepL.com/Translator

Image

(Click to enlarge)

Online now: No Back to the top
1 guest and 0 members have just viewed this.