Persistent clipboard: metaclip
Jul 15, 2012 20:01:24 GMT 1
Post by agent725 on Jul 15, 2012 20:01:24 GMT 1
Hi guys. In our small company Metasync we created a little program for Linux to 'remember' text placed in the clipboard after closing applications like for example Gedit and/or Zim. The self-cleaning clipboard feature drives some Linux users nuts, and BaCon helped out nicely.
My thanks to those who have made BaCon a reality. Now even non-experienced programmers can make a real difference. We now have a BaCon programmer employed.
Whenever we make something new in BaCon, we'll post it back here. It's the least we can do to show our appreciation. May the source be with you!
The timeout loop is very slow, to keep system resources free. Decrease the timeout if you like, for faster clipboard storage/restoration.
Additionally, in HUG you will need this, or something compatible:
My thanks to those who have made BaCon a reality. Now even non-experienced programmers can make a real difference. We now have a BaCon programmer employed.
Whenever we make something new in BaCon, we'll post it back here. It's the least we can do to show our appreciation. May the source be with you!
INCLUDE "hug.bac", CLIPBOARD, DISPLAY, GRAB$, INIT, TEXT, TIMEOUT
' Continous check
FUNCTION Clip_Loop
' Get clipboard contents
clipnewc$ = GRAB$(cbc)
clipnewp$ = GRAB$(cbp)
' Set clipboard contents
IF clipnewc$ = "" AND clipnewc$ != clipoldc$ AND clipnewp$ != "" THEN
clipnewc$ = clipoldc$
TEXT(cbc, clipnewc$)
PRINT "restoring clipboard (default)"
END IF
' Save clipboard contents
IF clipnewc$ != "" AND clipnewc$ != clipoldc$ THEN
clipoldc$ = clipnewc$
PRINT "saving clipboard (default)"
ENDIF
' Let's repeat this function
RETURN TRUE
END FUNCTION
INIT
' Create a clipboard
cbc = CLIPBOARD("CLIPBOARD")
cbp = CLIPBOARD("PRIMARY")
' Set default variables
clipoldc$ = ""
' Create the continuous check
PRINT "HOLOS clipboard manager - Joachim de Koning"
TIMEOUT(1000, Clip_Loop)
DISPLAY
END
The timeout loop is very slow, to keep system resources free. Decrease the timeout if you like, for faster clipboard storage/restoration.
Additionally, in HUG you will need this, or something compatible:
FUNCTION CLIPBOARD (STRING target$)
LOCAL clip, atom
atom = gdk_atom_intern(target$, 0)
clip = gtk_clipboard_get(atom)
hug_widget_type$(STR$(clip)) = "clipboard"
RETURN clip
END FUNCTION