|
Clipboard |
Trezker
Member #1,739
December 2001
|
Oh terribly sorry. I forgot you have to run I did that since I thought I'd add other options later, like -set [text] and -get that would just print and return. |
BAF
Member #2,981
December 2002
|
Trezker said: I felt it strange with the naming, since I'm performing the copy action in my application but I'm pasting into the clipboard, so what should the name of the function be? You're copying to the clipboard. You don't paste things to the clipboard, you paste things from it. |
bamccaig
Member #7,536
July 2006
|
Hopefully I'm not stepping on anyone's toes. I've updated the code using pipes instead of a shell (i.e., system). I've also updated the code to copy error messages into a static buffer, and exposed an accessor function to retrieve it. http://github.com/bamccaig/clipboard 1int size;
2const char * text = getText(&size);
3
4if(!Set_clipboard_text(text, size))
5{
6 fprintf(
7 stderr,
8 "Failed to set clipboard text: %s\n",
9 Get_clipboard_errmsg());
10}
11
12char * clipboard_text = Get_clipboard_text();
13
14if(clipboard_text)
15{
16 printf("Clipboard text: {%s}\n", clipboard_text)
17}
18else
19{
20 fprintf(
21 stderr,
22 "Failed to get clipboard text: %s\n",
23 Get_clipboard_errmsg());
24}
-- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Trent Gamblin
Member #261
April 2000
|
Are you still using xclip or have you molded the source into a library? Using a external command line utility feels really dirty.
|
bamccaig
Member #7,536
July 2006
|
Trent Gamblin said: Are you still using xclip or have you molded the source into a library? Using a external command line utility feels really dirty. We are still using xclip in Linux. I imagine we would want to eventually eliminate that dependency and directly access the clipboard in X, but I don't think that any of us currently know how. Besides, it's not that dirty in a UNIX world. After all, that's what pipes are for. In UNIX you can sort of think of programs as subroutines on a higher-level (so I guess just routines ). AFAIK, threads in Linux are even executed as separate processes. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Trent Gamblin
Member #261
April 2000
|
You could know how by looking at the xclip source code. I imagine the actual interface (accepting command line arguments and outputting text to the console) is pretty minimal and could be swapped out for something that writes to a memory buffer pretty easily.
|
bamccaig
Member #7,536
July 2006
|
/me will attempt it. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Trezker
Member #1,739
December 2001
|
I've tried looking through the xclip source a couple of times. But I fear I'll end up in a mental hospital if I make a serious attempt to extract what we need from it. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
The real question is, has anyone tried to paste into other programs with one of the Linux versions we have created? While digging around on the internet, I found these : Trezker, I tried building your latest version and the makefiles are generated by premake, but then when I run mingw32-make there is an error. It says "'cc' is not recognized as an internal or external command". I can't find a reference to cc anywhere in the makefiles though. I don't even know what cc is for. I know $(CC) is the compiler symbol but that is set to gcc everywhere it is used. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Arthur Kalliokoski
Second in Command
February 2005
|
The "cc" command is for old pre-gcc compilers. "c compiler" as opposed to "gnu c compiler". Make an alias or something. They all watch too much MSNBC... they get ideas. |
GullRaDriel
Member #3,861
September 2003
|
In short, with mingw use gcc instead of cc. "Code is like shit - it only smells if it is not yours" |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Arthur Kalliokoski said: Make an alias or something. I tried doskey cc=gcc but mingw32-make still fails. cc isn't even in the makefile but it's still being called for some reason. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Arthur Kalliokoski
Second in Command
February 2005
|
Try "copy \dgjpp\bin\gcc.exe \djgpp\bin\cc.exe" ? They all watch too much MSNBC... they get ideas. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Well, that worked, but I still don't see how the makefiles are calling cc in any way. A couple warnings and errors occurred while building : c:\ctwoplus\progcode\allegro\ClipboardLibrary\Trezker\trezker-clipboard-925faba>mingw32-make "==== Building clipboard (debug) ====" windows.c Linking clipboard "==== Building terminal (debug) ====" terminal.c ../examples/terminal.c: In function `interactive': ../examples/terminal.c:19: warning: implicit declaration of function `strndup' ../examples/terminal.c:19: warning: initialization makes pointer from integer without a cast Linking terminal ld: cannot find -lallegro mingw32-make[1]: *** [examples/terminal.exe] Error 1 mingw32-make: *** [terminal] Error 2 c:\ctwoplus\progcode\allegro\ClipboardLibrary\Trezker\trezker-clipboard-925faba>examples\terminal.c c:\ctwoplus\progcode\allegro\ClipboardLibrary\Trezker\trezker-clipboard-925faba> strndup is not declared in the version of string.h that came with MinGW 3.4.5 and it tries to link against liballegro.a which doesn't exist. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Arthur Kalliokoski
Second in Command
February 2005
|
Edgar Reynaldo said: strndup is not declared in the version of string.h that came with MinGW 3.4.5 I remember having trouble with string.h vs. strings.h, although I can't remember if it was with MinGW or not. See if you have both, maybe strings.h will fix it. They all watch too much MSNBC... they get ideas. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I used grep to search mingw\include for strndup but it came up empty. So even if there is a strings.h it doesn't have strndup either. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Arthur Kalliokoski
Second in Command
February 2005
|
Maybe try make your own version? Fiddle with this awhile. http://www.koders.com/c/fid1A3888AD28AC5BE48759EE95EBC5E6CF975A3652.aspx They all watch too much MSNBC... they get ideas. |
GullRaDriel
Member #3,861
September 2003
|
Plus it's a simple 5 minute hack ^^ "Code is like shit - it only smells if it is not yours" |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Trezker, I got your premake4.lua script to work, with a couple of changes. windows.c didn't include <stdio.h> for printf. Changed lines are highlighted below : 1lib_name = "clipboard"
2dependencies = { }
3
4solution (lib_name)
5 configurations { "Debug", "Release" }
6
7 project (lib_name)
8 kind "StaticLib"
9 language "C"
10 location "build"
11 targetdir "build/lib"
12 includedirs { "include" }
13
14 configuration "Debug"
15 defines { "DEBUG" }
16 flags { "Symbols" }
17
18 configuration "Release"
19 defines { "NDEBUG" }
20 flags { "Optimize" }
21
22 configuration "linux"
23 files { "src/linux.c" }
24
25 configuration "windows"
26 files { "src/windows.c" }
27
28-- ex_dependencies = {"allegro","allegro_image" } 29 examples = os.matchfiles("examples/*.c")
30 for index, name in pairs(examples) do
31 sname = name:sub(10, name:len()-2);
32 project (sname)
33 kind "ConsoleApp"
34 language "C"
35 location "build"
36 files { name }
37 includedirs { "src" }
38-- libdirs { "../lib" }
39 links (lib_name)
40-- links (ex_dependencies) 41 targetdir "build/examples"
42-- postbuildcommands { "cd .. && build/examples/"..sname }
43
44 configuration "Debug"
45 defines { "DEBUG" }
46 flags { "Symbols", "ExtraWarnings" }
47 links { "alld" } 48
49 configuration "Release"
50 defines { "NDEBUG" }
51 flags { "Optimize", "ExtraWarnings" }
52 links { "alleg" } 53 end
54
55newoption {
56 trigger = "dir",
57 value = "path",
58 description = "Choose a path to install dir",
59}
60
61newaction {
62 trigger = "install",
63 description = "Install the software",
64 execute = function ()
65 -- copy files, etc. here
66 os.mkdir(_OPTIONS["dir"].."lib/");
67 files = os.matchfiles("build/lib/*")
68 print ("Installing lib files to " .. _OPTIONS["dir"] .."lib/")
69 for k, f in pairs(files) do
70 print ("Copying " .. f)
71 os.copyfile(f, _OPTIONS["dir"].."lib/")
72 end
73 os.mkdir(_OPTIONS["dir"].."include/"..lib_name.."/");
74 files = os.matchfiles("src/*.h")
75 print ("Installing header files to " .. _OPTIONS["dir"] .."include/")
76 for k, f in pairs(files) do
77 print ("Copying " .. f)
78 os.copyfile(f, _OPTIONS["dir"].."include/"..lib_name.."/")
79 end
80 end
81}
82
83if not _OPTIONS["dir"] then
84 _OPTIONS["dir"] = "/usr/local/"
85end
86
87if not ("/" == _OPTIONS["dir"]:sub(_OPTIONS["dir"]:len())) then
88 _OPTIONS["dir"] = _OPTIONS["dir"] .. "/"
89end
mingw32-make worked fine with the changes I made. The install target did not exist however. Here's what mingw32-make help replied : c:\ctwoplus\progcode\allegro\ClipboardLibrary\Trezker\trezker-clipboard-925faba>mingw32-make help "Usage: make [config=name] [target]" "" "CONFIGURATIONS:" " debug" " release" "" "TARGETS:" " all (default)" " clean" " clipboard" " terminal" "" "For more information, see http://industriousone.com/premake/quick-start" c:\ctwoplus\progcode\allegro\ClipboardLibrary\Trezker\trezker-clipboard-925faba> I noticed that the premake script had an install target so I typed 'premake4 install' and that triggered the install script but I forgot to set the dir option so it copied to usr/local and said : c:\ctwoplus\progcode\allegro\ClipboardLibrary\Trezker\trezker-clipboard-925faba>premake4 install Building configurations... Running action 'install'... Installing lib files to usr/local/lib Copying build/lib/libclipboard.a Installing header files to usr/local/include Copying src/clipboard.h Done. c:\ctwoplus\progcode\allegro\ClipboardLibrary\Trezker\trezker-clipboard-925faba> However, these must have failed silently since usr/local doesn't exist. I've been looking, but is there a way to tell premake4 to display the commands it runs? I hate not knowing what it's actually doing. I think today I'll look over the ICCCM I mentioned earlier. However, I think that using selections on Linux may take a little hacking into Allegro, I'm not sure yet though. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
bamccaig
Member #7,536
July 2006
|
That was probably /usr/local/foo, which in Windows should translate to "%CURRENTDRIVE%\usr\local\foo". You might want to look for it there. Though the install target usually actually installs the library into the system, and I wouldn't say that this library is anywhere near stable enough to bother. You should be able to just build it something like this: premake4 gmake make At least, that is how to do it in Linux using GNU make. I don't know about Windows and MinGW. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Edgar Reynaldo
Major Reynaldo
May 2007
|
bamccaig said: That was probably /usr/local/foo, which in Windows should translate to "%CURRENTDRIVE%\usr\local\foo". You might want to look for it there. Just to be sure, I checked and there is a c:\usr\local folder now, with include and lib folders and a clipboard folder in the include folder. However, all of those folders are empty, even after running 'premake4 install' several times. So the install target is still failing somehow. bamccaig said: and I wouldn't say that this library is anywhere near stable enough to bother. Fine, but there's no reason the build system should be neglected either. bamccaig said: At least, that is how to do it in Linux using GNU make. I don't know about Windows and MinGW. Pretty similar on Windows with MinGW : premake4 gmake mingw32-make I was wondering though, is there a way to write the premake script so that the resulting makefiles have an install target, as well as so that they output the actual commands they are using to build the target? I know you can run make with the '-n' flag so that it doesn't build but instead prints out the commands it would have used, but that's not the same as doing it at the same time as it builds the project. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Trezker
Member #1,739
December 2001
|
Could you possibly fork the clipboard project on github, that'd make it easy for me to merge your changes. The install script in premake is only for Linux since I coded it for my own use. I don't think premake has any crossplatform method for installing. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Trezker said: Could you possibly fork the clipboard project on github, that'd make it easy for me to merge your changes. I don't use git, and I don't know what you mean by fork the project. Can't you just edit your local copy and then use 'git commit' or something? Trezker said: So if you wish for premake to install correctly in windows, you need to either give it a different directory. I tried this twice using the --dir option, and it still doesn't copy any files. It made a new folder called clipboard in c:\mingw\include but it was empty. clipboard.h wasn't in c:\mingw\include, and libclipboard.a wasn't in c:\mingw\lib. So I don't know why os.copyfile isn't working correctly. Edit : My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
bamccaig
Member #7,536
July 2006
|
Edgar Reynaldo said: I don't use git, and I don't know what you mean by fork the project. Can't you just edit your local copy and then use 'git commit' or something? See my PM. In addition to that, forking is basically the process of cloning somebody else's repository (normal for distributed SCMs) and then adding your changes to that. GitHub makes forking really simple because it is smart enough to use pointers to other people's repositories to save space. So when you fork somebody's repository in GitHub it's very efficient. It also tracks forks and makes it really easy for the original project developer(s) to pull your changes into the main repository. So collaboration is made really easy. Edgar Reynaldo said: I know why os.copyfile isn't working correctly. The script is using forward slashes to produce the paths when it should be using backslashes on windows.
Windows understands forward slashes just fine. It's only really dumb Windows command line clients that use forward-slash for -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I installed Git and cloned Trezker's clipboard repo. What now? Even if I make changes, the repo is still read only so I can't commit changes. bamccaig said: It's only really dumb Windows command line clients that use forward-slash for options switches that don't understand those path separators. True, but if you ever plan on installing anything on Windows you have to play nice and use forward slashes. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
|