Clipboard / Gambas IDE question - ASCIIFrame

Post your Gambas programming questions here.
Post Reply
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Clipboard / Gambas IDE question - ASCIIFrame

Post by Diverod »

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.
Attachments
ASCIIFrame.tar.gz
(46.35 KiB) Downloaded 170 times
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Clipboard / Gambas IDE question - ASCIIFrame

Post by BruceSteers »

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?)
If at first you don't succeed , try doing something differently.
BruceS
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Re: Clipboard / Gambas IDE question - ASCIIFrame

Post by Diverod »

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: Select all

Clipboard.Copy(sAll, "text/plain")
in the app trying to cover the bases properly, but no go with that either. Thanks Bruce.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Clipboard / Gambas IDE question - ASCIIFrame

Post by BruceSteers »

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.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Clipboard / Gambas IDE question - ASCIIFrame

Post by BruceSteers »

i pasted this in gambas after pressing copy button...

Code: Select all

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

is that right?
If at first you don't succeed , try doing something differently.
BruceS
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Re: Clipboard / Gambas IDE question - ASCIIFrame

Post by Diverod »

BruceSteers wrote: Wednesday 22nd December 2021 2:52am i pasted this in gambas after pressing copy button...

Code: Select all

''     ╔════════════════════════════════════════════════════════════════════╗
''     ║                 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.
dinge
Posts: 12
Joined: Friday 5th June 2020 7:37pm

Re: Clipboard / Gambas IDE question - ASCIIFrame

Post by dinge »

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: Select all

#!/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
Post Reply