Clipboard / Gambas IDE question - ASCIIFrame

Post

Posted
Rating:
#1 (In Topic #788)
Regular
Diverod is in the usergroup ‘Regular’
 When I copy my info to the Clipboard with this app, I can’t paste it into the Gambas Fmain.class.

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.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
 I had something's by like this once. I think I fixed it using Gambas advanced paste, (paste as text/plain option)

Does anything paste directly? (Any text or just nothing?)
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
Diverod is in the usergroup ‘Regular’
I tried the Advanced paste option in Gambas (hadn't tried before) but same results.

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")
in the app trying to cover the bases properly, but no go with that either. Thanks Bruce.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
 are you trying to paste into the ASCIIFrame gambas code window as that won't work.

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.
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’
i pasted this in gambas after pressing copy button…

Code

''     ╔════════════════════════════════════════════════════════════════════╗
''     ║                 My Naming Conventions for Controls                 ║
''     ║                                                                    ║
''     ║                My Naming Conventions for Variables                 ║
''     ║                                                                    ║
''     ╚════════════════════════════════════════════════════════════════════╝


is that right?
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
Diverod is in the usergroup ‘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.
Online now: No Back to the top

Post

Posted
Rating:
#7
Trainee
Dear mr Diverod, BruceSteers
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
Online now: No Back to the top
1 guest and 0 members have just viewed this.