|
Clipboard |
Trezker
Member #1,739
December 2001
|
Create account on github, when logged in go to my repository. In the top right region you'll see a fork button, use it. |
bamccaig
Member #7,536
July 2006
|
^ After that,... I think GitHub requires the use of public key cryptography (I may be wrong so ignore this if I am), so you'll likely need to generate keys and copy the public one to GitHub. If you're using Windows then I assume you are using msysGit. You should be able to find a .ssh directory either at $MSYSROOT/home/username/.ssh or at %USERPROFILE%\.ssh. If there's an id_rsa.pub file then copy it's contents into a new public key here. If not, then you'll need MSYS's ssh-keygen to generate some keys. Run it without arguments and it should do the right thing. Just use the default options (except you should specify a pass-phrase for better security so do that). Then you'll probably want to fix the remote repositories in your local clone. I like to call my own GitHub account "origin" (the default name for the originally cloned remote), so I name the furthest upstream "root" to differentiate. I don't know what other people do. The names are only for your reference anyway. You can call your own remote whatever you want, but you'll need to add it so that you can push to it later. $ git remote -v origin git://github.com/trezker/clipboard.git (fetch) origin git://github.com/trezker/clipboard.git (push) $ git remote rename origin root $ git remote add origin git@github.com:<username>/clipboard.git $ git remote -v origin git@github.com:<username>/clipboard.git (fetch) origin git@github.com:<username>/clipboard.git (push) root git://github.com/trezker/clipboard.git (fetch) root git://github.com/trezker/clipboard.git (push) Optionally: You'll probably also want to change the master branch's remote tracked branch to be your own instead of Trezker's. This is so that without specifying a remote repository Git will automatically pick the one that you use most often. I usually set this to my own GitHub account. --- .git/config +++ .git/config @@ -7,7 +7,7 @@ fetch = +refs/heads/*:refs/remotes/origin/* url = git@github.com:bamccaig/clipboard [branch "master"] - remote = root + remote = origin merge = refs/heads/master [remote "root"] url = git://github.com/trezker/clipboard
Then, after you've committed your changes to your local repository, push them up to your GitHub account: $ git push # -- OR if you haven't set up the tracked # -- branch properly, specify the remote # -- and branch: $ git push origin master Then, you can either use GitHub to send Trezker a pull request, or you can just communicate with him the old fashioned way and tell him to pull from your repository. -- 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
|
Heh, I didn't think of the cryptokey. I don't really know how smooth it is in windows though. |
MiquelFire
Member #3,110
January 2003
|
I use the Putty tools, so it's really easy. But then, I use hg-git to use github anyway. --- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Okay, I created an account on GitHub, setup my public key, and forked Trezker's project. I followed bamccaig's setup advice to rename origin to root and set origin to my git repo. Then I set the master branch's root to the new origin using .git/config. bamccaig said: Then, after you've committed your changes to your local repository, push them up to your GitHub account: I'm a little lost here. Steps to follow (I think, but I'm probably wrong) : Is that about right? Cause I don't know shit about git. 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
|
Yep, that sounds pretty much correct. Let us know if you have issues with any of 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 |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I've made some changes I want to get rid of. How do I revert to the last/original state of the local repository? 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 |
Trezker
Member #1,739
December 2001
|
http://book.git-scm.com/4_undoing_in_git_-_reset,_checkout_and_revert.html If you feel you need to add something more to the same commit, you can amend http://www.jukie.net/bart/blog/git-amend There's also rebasing, but try to avoid that. |
bamccaig
Member #7,536
July 2006
|
Trezker said: There's also rebasing, but try to avoid that. He's lying![1] Rebasing can do exactly what you need. It can be somewhat dangerous though so you'll need to be careful. $ git rebase --interactive <commit_id> First, you need to know the commit identifier for the commit just before the one(s) that you wish to modify. You can use git log to check. Alternatively, you can use a relative number from a known commit, if you know that. For example, if you've committed 4 times onto the master branch then you could use 5. $ git rebase -i master~5 This should open your favorite text editor with a list of commits and instructions at the bottom. Modify the command word in front of every commit that you wish to modify (or delete the commit line entirely to remove that commit). When finished, save and exit the text editor. The changes will be made. If it stops along the way, use git rebase --continue to proceed once you've resolved conflicts or completed your changes, and use git rebase --abort if you wish to undo your changes and revert back to how they were before you started rebasing. Read git help rebase for more. Technically, I don't think git modifies or deletes the original commits, but rather duplicates them and recommits them onto their parents. Then it hides the originals somehow. I think if you remember the commit identifier then you should still be able to recall such a commit. I could be wrong. It doesn't matter because when you push or pull only the necessary commits will get sent. Those that are effectively orphaned or forgotten will not be. I recommend you make a backup (tar.gz or zip) before attempting to rebase if you're new to it. It can be confusing doing it the first few times and it helps to know without a doubt that you can't break anything. References
-- 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
|
Okay, I'll take a look at those links. Installing and uninstalling now work properly on my machine. I pushed the changes up to my repo - https://github.com/Edgar-Reynaldo/clipboard. There were some minor changes to the source files and strndup was replaced with regular code doing the same thing because strndup is not implemented in MinGW 3.4.5. I cleaned up and fixed premake4.lua so copying files worked and added an uninstall target to it. Take a look and see what you think. 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
|
I've merged your stuff but I also cleaned up a bit. So update on your side. I noticed you added linking to allegro 4, but the code in repo doesn't use it yet so I commented those lines for now. I think once code that requires allegro is in there we should support both allegro 4 and 5. I think premake will let us add configuration options for this easily. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Trezker said: I've merged your stuff but I also cleaned up a bit. So update on your side. I did 'git fetch root' and it appeared to update my repo, but I don't see anything different. I tried 'git diff HEAD~1' but that only gave my the changes I committed, not yours. Also, how do you quit the git diff viewer? I've tried ESC, CTRL+C, quit<enter>, so on... but nothing works. I have a question about the way xcip works. Using your terminal.exe program on Linux, can you copy text from another program and then use the 'get' command and see whether xclip reads a global selection or whether it just uses it's own internal buffer. I'm going to take a more serious look at using selections tomorrow. 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
|
You exit with Q. xclip works against the system clipboard. So yes, you get the global selection. |
bamccaig
Member #7,536
July 2006
|
Edgar Reynaldo said: I did 'git fetch root' and it appeared to update my repo, but I don't see anything different. As Trezker pointed out, fetch only downloads commits. It doesn't merge them into your own branch. You'll have to merge it into your own branch if you want that to happen. I've been experimenting with this just recently so that I could understand it better. For starters, a really useful command is: $ git log --graph It basically shows you a text-based "graphical" representation of the history. Lets you visualize branching and such. You can also specify paths. $ git log --graph master root/master That should show you history for both 'master' and 'root/master' branches. For me, after fetching, I can see two new commits that I haven't merged into my master branch yet: Quote:
* commit ec7dd317751516472e40d2efbdef8d2521784e02 | Author: Anders Andersson <trezker@gmail.com> | Date: Mon Jan 17 17:25:15 2011 +0100 | | Small cleanup of Edgars version | * commit 9073608c1b6f77b459d7adf17e9d29be07456a85 | Author: Edgar Reynaldo <nospam@toobadsosad.com> | Date: Mon Jan 17 07:16:21 2011 -0600 | | Minor changes plus revision of premake4.lua to fix file copy and add uninstall target | | * commit 27b4c95e0eb9f68af1c7bd808a51a3c2f06d1090 | |\ Merge: cd9cf94 67dbdf2 | |/ Author: Brandon McCaig <bamccaig@gmail.com> |/| Date: Mon Jan 17 09:23:39 2011 -0500 | | | | Merge remote branch 'root/master' | | *snip*
IIRC, the last one you see there is from the last time I did a fetch and merge (experimenting). Notice how the history stops there. After that * there's no paths further upward. To the left of that is another path (branch) that has two commits: "Minor changes plus..." and "Small cleanup..." That is the root/master branch that I've fetched and not yet merged. I can merge them into my master branch like this: # This is probably already done, but just for completeness. $ git checkout master # Merge with the remote branch. $ git merge root/master Merge made by recursive. examples/terminal.c | 36 ++++++++++++------- premake4.lua | 97 +++++++++++++++++++++++++++++++++++++++++++++------ src/clipboard.h | 2 +- src/linux.c | 2 +- src/windows.c | 5 +++ 5 files changed, 116 insertions(+), 26 deletions(-) Now if we visualize the history again: $ git log --graph master root/master We get this: Quote:
* commit c472f08de68d296b24eb1020908945925710abb4 |\ Merge: 27b4c95 ec7dd31 | | Author: Brandon McCaig <bamccaig@gmail.com> | | Date: Tue Jan 18 09:42:10 2011 -0500 | | | | Merge remote branch 'root/master' | | | * commit ec7dd317751516472e40d2efbdef8d2521784e02 | | Author: Anders Andersson <trezker@gmail.com> | | Date: Mon Jan 17 17:25:15 2011 +0100 | | | | Small cleanup of Edgars version | | | * commit 9073608c1b6f77b459d7adf17e9d29be07456a85 | | Author: Edgar Reynaldo <nospam@toobadsosad.com> | | Date: Mon Jan 17 07:16:21 2011 -0600 | | | | Minor changes plus revision of premake4.lua to fix file copy and add uninstall target | | * | commit 27b4c95e0eb9f68af1c7bd808a51a3c2f06d1090 |\ \ Merge: cd9cf94 67dbdf2 | |/ Author: Brandon McCaig <bamccaig@gmail.com> | | Date: Mon Jan 17 09:23:39 2011 -0500 | | | | Merge remote branch 'root/master' | | *snip*
We can see that my master branch (now on the left instead of right) joins up with the remote branch. I think that fetch is used to look around at remote branches to see what has been done and determine if you want to merge. For example, it seems you can: $ git checkout root/master This should let you view history, build and run the modified code, and determine just what was done and whether or not you actually want it. Contrarily: $ git pull root master Basically skips the review step and just merges right in. So pull would be useful if you were pulling in permanent changes from upstream, but fetch would be useful if you were just reviewing experimental changes from elsewhere and didn't necessarily want to merge with them. I think. It's something that I've been wondering about for a while. In Mercurial, there are two pretty simple commands: hg incoming and hg outgoing that tell you which commits, if any, would be pulled or pushed. I'm sure there's a reason Git is designed the way it is though. I think I'm starting to figure out the Git way and I rather do like it (I use Mercurial at j0rb so I'm forced to learn about it faster). -- 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've got a basic handle on using selections. I think I can get by without sending/receiving any events in Linux, but I'm not totally sure. Here's my first attempt : 1
2#include <xalleg.h>
3
4int SetClipboardString(const char* cstr) {
5 Display* d = _xwin.display;
6 Window w = _xwin.window;
7 char* str = 0;
8
9 if (!cstr) {return 1;}
10 str = strdup(cstr);
11 XChangeProperty(d , w , XA_CLIPBOARD , XA_STRING , 8 , PropModeReplace , (unsigned char*)str , strlen(str) + 1);
12 XFlush(d);
13 free(str);
14 XSetSelectionOwner(d , XA_CLIPBOARD , w , CurrentTime);
15 return 0;
16}// returns 0 if successful, non-zero otherwise
17
18
19
20int SetClipboardBitmap(BITMAP* bmp) {
21 return 1;// not implemented yet
22}// returns 0 if successful, non-zero otherwise
23
24
25
26char* GetNewClipboardString() {
27 Display* d = _xwin.display;
28 Window w = _xwin.window;
29 Atom returned_type;
30 int returned_format;
31 unsigned long num_items_returned;
32 unsigned long bytes_left;
33 unsigned char* returned_property;
34 char* return_string = 0;
35 int ret = 0;
36 char* AtomName = 0;
37
38 Window selowner = XGetSelectionOwner(d , XA_CLIPBOARD);
39 if (selowner == None) {return (char*)0;}
40 XConvertSelection(d , XA_CLIPBOARD , XA_STRING , None , selowner , CurrentTime);
41 XFlush(d);
42
43 // check for data
44 ret = XGetWindowProperty(d , selowner , XA_STRING , 0 , 0 , 0 , AnyPropertyType , &returned_type ,
45 &returned_format , &num_items_returned , &bytes_left , &returned_property);
46 if (ret != Success) {
47 fprintf(Log() , "Failed to Get Window Property XA_STRING attempt 1\n")
48 return (char*)0;
49 }
50 if (bytes_left < 1) {
51 fprintf(Log() , "There are no bytes to read in the requested property.\n");
52 return (char*)0;
53 }
54 ret = XgetWindowProperty(d , selowner , XA_STRING , 0 , bytes_left*4 , 0 , AnyPropertyType , &returned_type ,
55 &returned_format , &num_items_returned , &bytes_left , &returned_property);
56 if (ret != Success) {
57 fprintf(Log() , "Failed to Get Window Property XA_STRING attempt 2\n");
58 return (char*)0;
59 }
60 // Success, temporary logging of returned data
61//*
62 AtomName = XGetAtomName(d , returned_type);
63 if (!AtomName) {AtomName = "Unidentified Atom";}
64 fprintf(Log() , "Success retrieving property. Return type \"%s\" , Format=%d , NumItemsReturned=%d\n"
65 " Bytes Left=%d , String Returned=\"%s\"" ,
66 AtomName , returned_format , num_items_returned , bytes_left , returned_property);
67 if (strcmp(AtomName , "Unidentified Atom") != 0) {XFree(AtomName);}
68//*/
69 if (returned_format == 8) {
70 return_string = strdup(returned_property);
71 } else {
72 fprintf(Log() , "The string returned was not in char format. Data size was %d." , returned_format);
73 }
74 XFree(returned_property);
75
76 return return_string;
77}// returns a new string if successful, else returns 0
78
79
80
81BITMAP* GetNewClipboardBitmap() {
82 return 0;// not implemented yet
83}// returns a new bitmap if successful, else returns 0
Can someone compile and test this on Linux please? Use the S key to set the clipboard text to "CyberMan" and use the B key to retrieve the clipboard text. It doesn't work with images yet because I can't find out what the standard expected format for an image in the Linux clipboard is supposed to be. I've googled and googled with no results. I'm downloading the source to Gimp now, so maybe that can give me a clue. Does Gimp let you copy and paste images between programs on Linux? If it doesn't, what programs do? 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
|
ClipboardTest.c compiled OK, but ClipboardTest.c brought up all these errors: pepsi@fractalcomet:/home/prog/ClipBoardTest3 05:14 AM $ gcc -c -O2 -Wall Clipboard.c Clipboard.c:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token Clipboard.c:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token Clipboard.c: In function 'SetClipboardString': Clipboard.c:225: error: 'XA_CLIPBOARD' undeclared (first use in this function) Clipboard.c:225: error: (Each undeclared identifier is reported only once Clipboard.c:225: error: for each function it appears in.) Clipboard.c:225: error: 'XA_STRING' undeclared (first use in this function) Clipboard.c: In function 'GetNewClipboardString': Clipboard.c:252: error: 'XA_CLIPBOARD' undeclared (first use in this function) Clipboard.c:254: error: 'XA_STRING' undeclared (first use in this function) Clipboard.c:261: warning: implicit declaration of function 'Log' Clipboard.c:261: warning: passing argument 1 of 'fprintf' makes pointer from integer without a cast /usr/include/stdio.h:333: note: expected 'struct FILE * _restrict_' but argument is of type 'int' Clipboard.c:262: error: expected ';' before 'return' Clipboard.c:265: warning: passing argument 1 of 'fprintf' makes pointer from integer without a cast /usr/include/stdio.h:333: note: expected 'struct FILE * _restrict_' but argument is of type 'int' Clipboard.c:268: warning: implicit declaration of function 'XgetWindowProperty' Clipboard.c:271: warning: passing argument 1 of 'fprintf' makes pointer from integer without a cast /usr/include/stdio.h:333: note: expected 'struct FILE * _restrict_' but argument is of type 'int' Clipboard.c:280: warning: passing argument 1 of 'fprintf' makes pointer from integer without a cast /usr/include/stdio.h:333: note: expected 'struct FILE * _restrict_' but argument is of type 'int' Clipboard.c:280: warning: format '%d' expects type 'int', but argument 5 has type 'long unsigned int' Clipboard.c:280: warning: format '%d' expects type 'int', but argument 6 has type 'long unsigned int' Clipboard.c:284: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness /usr/include/string.h:397: note: expected 'const char *' but argument is of type 'unsigned char *' Clipboard.c:284: warning: pointer targets in passing argument 1 of '__strdup' differ in signedness /usr/include/bits/string2.h:1303: note: expected 'const char *' but argument is of type 'unsigned char *' Clipboard.c:286: warning: passing argument 1 of 'fprintf' makes pointer from integer without a cast /usr/include/stdio.h:333: note: expected 'struct FILE * _restrict_' but argument is of type 'int' Clipboard.c:242: warning: unused variable 'w' Clipboard.c: At top level: Clipboard.c:333: error: conflicting types for 'Log' Clipboard.c:261: note: previous implicit declaration of 'Log' was here Clipboard.c: In function 'Log': Clipboard.c:334: error: 'logfile' undeclared (first use in this function) Clipboard.c: In function 'CloseLog': Clipboard.c:343: error: 'logfile' undeclared (first use in this function)
pepsi@fractalcomet:/home/prog/ClipBoardTest3 05:14 AM $ gcc -v Reading specs from /usr/lib/gcc/i486-slackware-linux/4.4.4/specs Target: i486-slackware-linux Configured with: ../gcc-4.4.4/configure --prefix=/usr --libdir=/usr/lib --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,java,objc --enable-threads=posix --enable-checking=release --with-system-zlib --with-python-dir=/lib/python2.6/site-packages --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose --with-arch=i486 --target=i486-slackware-linux --build=i486-slackware-linux --host=i486-slackware-linux Thread model: posix gcc version 4.4.4 (GCC) Yes, you can copy and paste images.
They all watch too much MSNBC... they get ideas. |
GullRaDriel
Member #3,861
September 2003
|
Arthur said: ClipboardTest.c compiled OK, but ClipboardTest.c brought up all these errors: Which ClipboardTest.c are you talking about ? "Code is like shit - it only smells if it is not yours" |
Arthur Kalliokoski
Second in Command
February 2005
|
GullRaDriel said: Which ClipboardTest.c are you talking about ? The one in the zipfile? That causes Clipboard.c to complain about missing functions without it? They all watch too much MSNBC... they get ideas. |
GullRaDriel
Member #3,861
September 2003
|
OMG he doesn't see his mistake "Code is like shit - it only smells if it is not yours" |
Arthur Kalliokoski
Second in Command
February 2005
|
OK, I've been drinking again, but what mistake other than confusing the names? [EDIT] Or you mean this on line 150 in Clipboard.c? // #include <LINUX_HEADER> // TODO : Find out what linux header to include They all watch too much MSNBC... they get ideas. |
GullRaDriel
Member #3,861
September 2003
|
I just find it strange that the same file is able to compile fine and stop compiling by giving compilation errors at the same time. Other than the names, nothing else. But screwing the names screw the whole sentence, isn't it ? And we are, BTW, way out of topic ^^ "Code is like shit - it only smells if it is not yours" |
Trezker
Member #1,739
December 2001
|
Hi everybody. |
bamccaig
Member #7,536
July 2006
|
/congrats! -- 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 |
Arthur Kalliokoski
Second in Command
February 2005
|
Trezker said: My life just got turned upside down by getting a fulltime job. Something to do with computers, hopefully? They all watch too much MSNBC... they get ideas. |
Thomas Fjellstrom
Member #476
June 2000
|
-- |
|
|