Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sequential paste/"pop mode" (feature request) #44

Closed
scottkosty opened this issue May 8, 2013 · 19 comments
Closed

sequential paste/"pop mode" (feature request) #44

scottkosty opened this issue May 8, 2013 · 19 comments
Labels
feature New feature request

Comments

@scottkosty
Copy link
Collaborator

Suppose I want to copy a name, say Bob Smith, and an email, say
bobsmith@... from a document, into
a form that has three fields:
(1) First Name, (1) Last Name, and (3) email
I would like to be able to copy Bob, then copy Smith, then copy
bobsmith@... and then go to the form and paste one after
the other. It would be nice if after I pasted one, it was deleted from
CopyQ so I don't even have to go to the history and select the next
one, it's already loaded and ready to go. I think a fitting name could
be "pop mode" where after you paste
something, that entry just pop's off.

Could this be done with native paste directly? If CopyQ does not own
the paste, then it could still be implemented by using a different
key-binding. That is to say, you could allow the user to pick a
key-binding (default to ctrl+alt+v?) that, when called, would use the
system's paste function and then pop off the element in CopyQ.

@hluk
Copy link
Owner

hluk commented May 8, 2013

You can also copy the next or previous item in list without removing it -- not sure that it would be better -- it would be possible to copy items to a different tab and retrieve them any time.

Now you can paste item and select previous (no removal) with copyq eval 'paste();previous();'. But you need to activate the item you want to paste first in the main window or using "Copy next item" global shortcut -- but that's annoying :/.

So let's say I copy Bob, Smith and bobsmith@.... It would be stored in history in reverse order with the latest item selected. If I press the custom shortcut (e.g. ctrl+alt+v) I want Bob (the third item in the history) to be pasted first so it needs to be somehow found in the history.

Selecting the first item to paste could be simply done by checking the time when the item was copied -- i.e. the latest copied item is bobsmith@... and following is Smith which was copied few seconds before the latest item. Next item is Bob which is again only few seconds before Smith. Now, next item (if any) was copied a longer time ago so we've found Bob as the first candidate to paste. I guess the maximum interval between items can be up to 20 seconds (this would also allow user to reorder the items in list a bit).

Any ideas?

@scottkosty
Copy link
Collaborator Author

I like your idea about using the time between copies. I had never thought about that. I've been thinking about this feature for a long time but you've already thought through it better than I have.

I agree with what you say that you don't have to remove the item. In this issue I will use "pop paste" as the term because I can't think of a name for the other implementation/mode ("moving paste" ?).

I see two cases where the time-based system would not be ideal:
(1) Continually using a different shortcut might be annoying to some (ctrl+alt+v does not seem inconvenient to me but maybe it is for others).
(2) A user wants "pop paste" but with lots of time in-between copies.
For example, suppose you are reading a long article and want to copy some quotes while you read and then paste them all at once at the end. Or, suppose you need to read through a lot of resumes and copy only the name and phone number of a few special candidates. But I think copyQ might have other ways of dealing with these situations.

Another possibility is to have a shortcut turn "pop paste" mode on. When activated by this shortcut, copyQ would switch to a new tab that has two special properties set: FILO and "pop".

Then, there are three possibilities for how the user transitions back from "pop paste" mode to normal mode:
(1) Normal mode is restored by using the same shortcut that is used to turn "pop pate" on.
(2) This mode is turned off automatically when the special copyQ tab is empty (when the last item was popped off).
(3) This mode is turned off automatically if there is a copy after there has been a paste. For example, suppose you turn the mode on, copy 5 elements, (pop) paste 3, and then copy something else.

Any combination of the above three also makes sense.

@hluk
Copy link
Owner

hluk commented May 13, 2013

In v1.8.2 I've implemented shortcuts "Paste and copy next/previous" to paste current clipboard and copy next/previous item in history. This seems to be the simplest solution for now. It's very close to what you describe but every time you need to start popping items you have to open copyq (tray menu or main window) or use "Copy previous item" shortcut and select the item you want to start with.

Having a new special tab when in "pop mode" could be quiet difficult to implement -- right now tabs don't have any properties or flags.

Well, the "pop" tab could be just a normal tab with some fixed name and items could be added with a custom shortcut (ctrl+alt+c) and paste+removed from the end of the tab with other shortcut (ctrl+alt+v). So there would be no special tab and no "pop mode".

Unfortunately you'll have to remember to use the shortcut to copy instead of ctrl+c and you'll have to remove the tab yourself if it's not needed anymore because otherwise the tab would be saved as normal tabs or paste+remove shortcut pastes something unexpected.

@scottkosty
Copy link
Collaborator Author

Thanks for implementing this. I can't seem to get it to work though. For me, "Paste and copy next" seems to be equivalent to "Copy next item" and same for "previous". Any ideas why the paste isn't getting executed/received? I've had this problem on Ubuntu 12.04 and 13.04.

@hluk
Copy link
Owner

hluk commented Jun 1, 2013

These new command actually only send Shift+Insert key press to current window. So this won't work if application don't paste using Shift+Insert or target window and input widget are not focused yet.

What application is it? Does it work in any app?

Other thing is that the "copy next/previous" can happen before the clipboard is pasted to target app. I've solved it with additional small wait interval after sending Shift+Insert.

@scottkosty
Copy link
Collaborator Author

I was testing in Gedit. Shift+Insert works, but the paste from the "Paste and copy next" shortcut does nothing.
In LibreOffice 4.0.2.2 I sometimes get the message "Requested clipboard format is not available." Other than that, it seems to work decently well. It also works well in LyX and Chromium. In any of the applications, it doesn't work well if I execute the shortcut fast -- often the same item is pasted two or three times in a row and skips the others. (Note that I don't have a use case for needing to be able to do it fast; I'm just testing).

In any case, you might have done everything you could. I guess a lot of this depends on the OS and the applications. Thank you for your work on this.

@hluk
Copy link
Owner

hluk commented Jun 1, 2013

OK, fixed.

Some apps like gedit ignore sent X11 events -- fortunately there is other way to do this, used e.g. by xdo utility.

You'll need libxtst-dev package. If you don't have the package installed (or it cannot be found) cmake will pop a warning and the old way will be used.

So if you can, please test it and close this task if it works well. I hope it will, I hate X11 and especially the API :).

@scottkosty
Copy link
Collaborator Author

It works great! It is much better than before. Thank you for sticking with this. This is a nice feature that I will use a lot and having to go to the menu to manually click where I want the starting point to be is not a problem for me at all. No more switching back and forth between applications to do mass copying!

I will note one thing (after which I think this can be closed). It sounds like you expect the compile to work if libxtst-dev is not installed. I tested this and got the following output:

$ cmake .
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt4: /usr/bin/qmake (found version "4.8.4") 
-- Building with Qt 4.
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Building for X11 window system.
CMake Warning at src/platform/x11/x11platform.cmake:10 (message):
  X11 'TEST' extension library is needed to be able to automatically paste to
  some windows!
Call Stack (most recent call first):
  src/platform/platform.cmake:5 (include)
  src/CMakeLists.txt:57 (include)


-- Building with ItemWeb plugin.
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
X11_XTest_LIB (ADVANCED)
    linked by target "copyq" in directory /home/scott/IndependentInstalls/CopyQ/src

-- Configuring incomplete, errors occurred!

@hluk
Copy link
Owner

hluk commented Jun 2, 2013

Oh, I'll fix that. Thanks for letting me know about this.

@hluk
Copy link
Owner

hluk commented Jun 2, 2013

If you have problems with shortcuts (e.g. system shortcuts not behaving correctly) let me know. Closing.

@hluk hluk closed this as completed Jun 2, 2013
@scottkosty
Copy link
Collaborator Author

You might have told me some other place, but currently cmake fails if libxtst-dev is not installed. A couple of comments up you suggest that this should not be the case. Is the policy now that it is required? I have no problem with this (I actually prefer it) but I just wanted to make sure that it is what you intended.

@hluk
Copy link
Owner

hluk commented Oct 25, 2013

Can you post the cmake output? I assume the culprit is commit 0a12ba7.

@scottkosty
Copy link
Collaborator Author

I get the following output

-- Building for X11 window system.
CMake Warning at src/platform/x11/x11platform.cmake:11 (message):
  X11 'TEST' extension library is needed to be able to automatically paste to
  some windows!
Call Stack (most recent call first):
  src/platform/platform.cmake:5 (include)
  src/CMakeLists.txt:29 (include)


-- Building with ItemWeb plugin.

I tested the commit before the one you suspect and I still get the error.

@hluk
Copy link
Owner

hluk commented Oct 25, 2013

That should be just a warning, i.e. it should continue after printing the message. Do you see any other error? Maybe with clean build?

@scottkosty
Copy link
Collaborator Author

You are right. I suppose I was confused because of the Call Stack output and the only four lines output afterward. But yes, the exit code of cmake is 0. However, when doing a clean build I get:

[ 55%] Building CXX object src/CMakeFiles/copyq.dir/platform/x11/x11platform.cpp.o
/home/scott/IndependentInstalls/CopyQ/src/platform/x11/x11platform.cpp:26:34: fatal error: X11/extensions/XTest.h: No such file or directory
compilation terminated.
make[2]: *** [src/CMakeFiles/copyq.dir/platform/x11/x11platform.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/copyq.dir/all] Error 2
make: *** [all] Error 2
$ 

@hluk
Copy link
Owner

hluk commented Oct 25, 2013

Oh, I see. You can just remove the line for now (#include <X11/extensions/XTest.h> in src/platform/x11/x11platform.cpp). I'll fix it later today. Thanks for the report.

@scottkosty
Copy link
Collaborator Author

Sounds good. Actually I prefer to install the package. Also, note that in INSTALL, libxtst-dev is not listed as optional.

@hluk
Copy link
Owner

hluk commented Oct 25, 2013

OK, I've fixed those (using github's internal editor, yay!).

@scottkosty
Copy link
Collaborator Author

Looks good. I like that you put descriptions for what the optional packages add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

2 participants