Page 1 of 2

Copy/Paste

Posted: Thu Jun 04, 2015 7:27 pm
by Bigjoe5
Copy/paste isn't working for me. There's some code in GUI.cpp that seems to be trying to implement an app-local copy-paste, but even that doesn't work. Does anyone know what's going on with this code? Is it working for anyone else?

Re: Copy/Paste

Posted: Thu Jun 04, 2015 7:29 pm
by Geoff the Medio
It only works in specific GUI widgets, and not any time when hotkeys are disabled, including when modal Wnds are open.

Re: Copy/Paste

Posted: Thu Jun 04, 2015 7:40 pm
by Bigjoe5
Ah, I see. I was only trying it in the "Rename Fleet" dialog, so that explains why it doesn't work.

I want to make copy-paste work on all dialogs and look at the system clipboard. I'll take a look at the code.

Re: Copy/Paste

Posted: Sun Jun 07, 2015 1:22 pm
by Vezzra
Bigjoe5 wrote:I want to make copy-paste work on all dialogs and look at the system clipboard.
Pre or post 0.4.5?

Re: Copy/Paste

Posted: Sun Jun 07, 2015 1:35 pm
by Geoff the Medio
Bigjoe5 wrote:I want to make copy-paste work on all dialogs and look at the system clipboard. I'll take a look at the code.
One of many things on my to-do list is making a bunch of modal windows not modal, in part so that copy-paste and similar hotkeys can work in them.

Re: Copy/Paste

Posted: Sun Jun 07, 2015 5:52 pm
by Bigjoe5
Vezzra wrote:
Bigjoe5 wrote:I want to make copy-paste work on all dialogs and look at the system clipboard.
Pre or post 0.4.5?
Post. I'll just make the branch of master and wait at least until the release branch is made to merge it.
Geoff the Medio wrote:
Bigjoe5 wrote:I want to make copy-paste work on all dialogs and look at the system clipboard. I'll take a look at the code.
One of many things on my to-do list is making a bunch of modal windows not modal, in part so that copy-paste and similar hotkeys can work in them.
For now, I'll just work on making it pull from the system clipboard then. Making modal windows non-modal can be a separate modification.

@Vezzra / Dilvish - I only have a working dev environment on Windows at the moment. This means I'm only going to be able to enable the system clipboard on windows, and will keep the functionality on Mac and Linux the same as it is now. I'll also have to get you guys to test my branch before I merge it into master, because I'll be making refactoring changes to sort out platform-specific clipboard code.

Re: Copy/Paste

Posted: Thu Jun 11, 2015 9:05 pm
by Bigjoe5
Added Windows-specific clipboard functionality. https://github.com/freeorion/freeorion/pull/118

Re: Copy/Paste

Posted: Thu Jun 11, 2015 9:46 pm
by Bigjoe5
New PR using the SDL2 clipboard API, as recommended by adrian_broher: https://github.com/freeorion/freeorion/pull/119

I can't really commit to fixing it before 0.4.5 release if something goes wrong, so you can hold off on merging it until after the release branch is made if you want.

Re: Copy/Paste

Posted: Fri Jun 12, 2015 7:40 am
by adrian_broher
Just an unrelated side note:

Could you please create pull requests from your own repository next time? Whenever you create a branch on the freeorion/freeorion repository everybody who forks it or fetches it also clones/fetches any branch that is part of this repository even it is completely irrelevant to him.

Re: Copy/Paste

Posted: Mon Jun 15, 2015 7:44 am
by Vezzra
Did a quick test on OSX, seems to work.

Re: Copy/Paste

Posted: Mon Jun 15, 2015 7:54 am
by Geoff the Medio
adrian_broher wrote:Could you please create pull requests from your own repository next time?
For my own recently-added pull request and branch, I attempted to use a branch under my account instead of within the freeorion organization, but couldn't figure out how to do so in the time I was willing to spend on it. I can make a branch on GitHub, or locally, but linking everything together as would be needed wasn't happening.

Re: Copy/Paste

Posted: Mon Jun 15, 2015 9:22 am
by adrian_broher
Geoff the Medio wrote:For my own recently-added pull request and branch, I attempted to use a branch under my account instead of within the freeorion organization, but couldn't figure out how to do so in the time I was willing to spend on it. I can make a branch on GitHub, or locally, but linking everything together as would be needed wasn't happening.
You have to do three steps to accomplish this.
  1. Create a fork of the project on github to have a place where you could push changes to.
  2. Add a remote to your local repository so git know were it can push to. On CLI this can be achieved by calling

    Code: Select all

    git remote add <remote-name> <remote-url>
    . Under TortoiseGit this can be configured in the Settings editor. By convention the name the remote you cloned from (and usually push to) is 'origin'. I use upstream for the freeorion/freeorion repository and origin for the adrianbroher/freeorion repository.
  3. Tell git to which repository it should push to when pushing changes. On CLI this can be achieved by calling

    Code: Select all

    git push <remote-name> <local-branch-name>:<branch-name-on-remote>
    . In TortoiseGit you can set the target remote and the branch names in the push dialogue.

Re: Copy/Paste

Posted: Thu Jul 16, 2015 11:18 am
by Geoff the Medio
Bigjoe5 wrote:New PR using the SDL2 clipboard API, as recommended by adrian_broher: https://github.com/freeorion/freeorion/pull/119
In a related matter, does anyone know how to, perhaps with SDL, send a URL to the OS to be opened in whatever is the default browser? Would be nice to have links to freeorion.org or copyright text websites work from in-game. My brief attempts to google for a simple platform-independent solution were unproductive.

Re: Copy/Paste

Posted: Thu Jul 16, 2015 11:48 am
by adrian_broher
Geoff the Medio wrote:In a related matter, does anyone know how to, perhaps with SDL, send a URL to the OS to be opened in whatever is the default browser? Would be nice to have links to freeorion.org or copyright text websites work from in-game. My brief attempts to google for a simple platform-independent solution were unproductive.
What about something like (based on http://stackoverflow.com/questions/1480 ... cation-for):

Code: Select all

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char** argv)
{
        const char* url = "http://www.freeorion.org/";
        char buffer[1024];

#ifdef _WIN32
        const char* command = "start %s";
#elif __APPLE__
        const char* command = "open %s";
#else
        const char* command = "xdg-open %s";
#endif

        sprintf(buffer, command, url);

        system(buffer);

        return 0;
}

Re: Copy/Paste

Posted: Thu Jul 16, 2015 11:53 am
by Geoff the Medio
That looks a bit unsafe / exploitable... Something that can only take (interpret as) a URL seems preferable...