Clipboard / Gambas IDE question - ASCIIFrame
Posted
#1
(In Topic #788)
Regular

I have to paste the Clipboard to a text editor, copy the contents back to the Clipboard and then I can paste it into the Gambas Fmain.class. This isn’t really a problem but I don’t understand why this happens.
It might just be me that this happens to or something within the Gambas editor itself. I’ve attached my code if anyone has some time to see if this happens to them or possibly explain why this happens.
Thanks for any input, RodG.
Posted
Guru

Does anything paste directly? (Any text or just nothing?)
Posted
Regular

Nothing at all gets pasted directly. If I Paste > Advanced > Comments I get a 'v and that's it. It's weird because I know it's in the Clipboard, as I can completely shut down Gambas and still paste the contents in a text editor. I did use
Code
Clipboard.Copy(sAll, "text/plain")
Posted
Guru

A clipboard text dies when a program exits.
So if you run your app, then you'd have to close it to paste text into the IDE, but the text is destroyed as app closes.
suggest installing clipit
sudo apt-get install clipit
clipit catches clipboards so they survive as apps close.
Posted
Guru

Code
'' ╔════════════════════════════════════════════════════════════════════╗
'' ║ My Naming Conventions for Controls ║
'' ║ ║
'' ║ My Naming Conventions for Variables ║
'' ║ ║
'' ╚════════════════════════════════════════════════════════════════════╝
is that right?
Posted
Regular

BruceSteers said
i pasted this in gambas after pressing copy button…Code
'' ╔════════════════════════════════════════════════════════════════════╗
'' ║ My Naming Conventions for Controls ║
'' ║ ║
'' ║ My Naming Conventions for Variables ║
'' ║ ║
'' ╚════════════════════════════════════════════════════════════════════╝
is that right?
Yes, that's what Doesn't happen for me. Do you have clipit installed?
I know what you mean about the clipboard dying when an app is closed, that's something I had to get use to. But, in this case I not only close the app but I also completely close Gambas and then open a text editor and can still paste the correct contents of the clipboard copied from the app.
I'm surely way out on an unimportant tangent here. Curiosity often gets the better of me.
Posted
Trainee
had a problem where the clipboard fuction, who works fine in a gambas execute file but did not work in a gambas script.
Solved this by using xclip and xsel. The little program is to upper/lower a letter and add or delete a "." from sentence.
Needed to use xclip an xsel as one copied correct but could not retrieve again from the clipboard, so used both, one for copy and the other for retrieving.
Maybe the code is a help for resolving this problem. I do not now if a missed a function or setting regarding the clipboard function in the gambas script but this works for me on any texteditor or program.
This here is limited to one letter, change the code for a whole sentence or text you want to be inserted.
You can also call with new coding the script with parameters.
I am shure there are Gambassers who can write much smaller and better code than this, i am a amateur Gambasser, so let the community know if it can be improved.
Hope this helps to adapt and solve clipboard copying with scripts.
Greetings Dinge
Code
#!/usr/bin/gbs3
Public Sub Main()
Dim oldletter as string
Dim oldselect as string
Dim newletter as string
shell "xsel -cb" wait
shell "xdotool key Shift+Right" wait to oldselect
if len(trim(oldselect)) > 0 then
oldletter = oldselect
oldselect=""
else
shell "xsel -cb" wait
shell "xdotool key Shift+Left" wait to oldselect
if len(trim(oldselect)) = "." then
oldletter = oldselect
else
oldletter = " "
endif
oldselect= ""
endif
shell "xclip -out -sel" to oldletter
shell "xsel -cb" wait
select case trim(oldletter)
case "."
shell "xdotool key Backspace" wait
shell "xdotool type " & "'" & "" & "'" wait
case " "
newletter = "."
shell "xdotool key Delete" wait
shell "xdotool type " & newletter & chr(32) wait
shell "xdotool key Left" wait
case else
newletter = upper(oldletter)
if newletter = oldletter then
newletter = lower(oldletter)
endif
newletter = "'" & newletter & "'"
shell "xdotool key Backspace" wait
shell "xdotool type " & newletter & chr(32) wait
shell "xdotool key Left" wait
end select
Print "OLD: "; oldletter ; " NEW: "; newletter
End
1 guest and 0 members have just viewed this.


