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

savannah: support for x clipboard wanted #30

Closed
mc-butler opened this issue Dec 25, 2008 · 40 comments
Closed

savannah: support for x clipboard wanted #30

mc-butler opened this issue Dec 25, 2008 · 40 comments
Labels
area: mcedit mcedit, the built-in text editor prio: low Minor problem or easily worked around
Milestone

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/30
Reporter ossi (@ossilator)
Mentions zaytsev (@zyv)
Keywords xclip, clipboard

Original: http://savannah.gnu.org/bugs/?13751

Submitted by:Oswald Buddenhagen <ossi>Submitted on:Tue 12 Jul 2005 10:44:23 AM UTC
Category:EditorSeverity:3 - Normal
Status:NonePrivacy:Public
Assigned to:NoneOpen/Closed:Open
Release:current (CVS or snapshot)Operating System:All

Original submission:

another one from the "hey, i'm an x application" department.
when running under x, it should be possible to use the x clipboard 
instead of mc's "proprietary" clip file. there should also be an 
option to make it the default, at least for the cua keybindings 
(the ones with shift & ctrl and the cursor block). there is one 
problem with xterm, though ... it steals us the shift-ins key combo 
to do X PRIMARY selection pasting itself. so unless there is a way 
to convince xterm not to do this (or at least a way to hack around 
it), we have a problem.

Comment 1 by Jan Engelhardt <hirogen2> at Sun 06 Jul 2008 04:19:44 PM UTC:

I run mc/mcedit always with the -d switch to deactivate mc's 
special mouse handling and get my X clipboard support (i.e. 
double-click to copy, middle button to paste) back.

Note

Original attachments:

@mc-butler
Copy link
Author

Changed by styx (@styx) on Feb 20, 2009 at 13:46 UTC (comment 1)

  • Milestone set to 4.7

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on May 23, 2009 at 21:00 UTC (comment 2)

fwiw, overriding xterm's mapping is in fact a FAQ. the solution is to add

XTerm*VT100*translations: #override \nShift <KeyPress> Insert:insert-eight-bit()

to the ~/.Xresources file (or whatever your setup has).

iow, there is nothing to make this feature unfeasible.

@mc-butler
Copy link
Author

Changed by slavazanko (@slavaz) on May 26, 2009 at 23:37 UTC (comment 3)

  • Milestone changed from 4.7 to future releases

I think, better to support XWindow clipboard more native - for example, pressing ALT+F (in additional) will add to Xclipboard current selection in editor...

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on May 27, 2009 at 20:24 UTC (comment 3.4)

Replying to slavazanko:

I think, better to support XWindow clipboard more native - for example, pressing ALT+F (in additional) will add to Xclipboard current selection in editor...

that's more explicit, but definitely not more native - quite to the contrary even, as the x clipboard is native in an x environment and can be expected to be found under the usual keybindings (that's why xterm has that keybinding in the first place). mc's own clipboard is still reachable via ctrl-f and shift-f5, so why deviate from the intuitive keybindings? one reason could be consistent access from mc instances running in consoles and in xterms at the same time. seems like a corner case which i would not want to sacrifice for better integration into the windowing environment. but that can be configurable as indicated in the original submission.

fwiw, given that you did not choose to use alt-shift-ins for vertical pasting, you could it use now to paste PRIMARY (as opposed to CLIPBOARD with shift-ins).

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Aug 17, 2009 at 17:15 UTC

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Aug 18, 2009 at 18:02 UTC (comment 5)

  • Severity set to no branch
  • Milestone changed from future releases to 4.7.0-pre3

@mc-butler
Copy link
Author

Changed by xintrea (xintrea@….com) on Sep 11, 2009 at 9:58 UTC (comment 6)

In path "editcmd.c xclip patch for 4.7.0-pre2" memory leak be present.

In functions edit_copy_to_X_buf_cmd() and edit_cut_to_X_buf_cmd() instead code

char *tmp; 
tmp = g_strconcat ("xclip -i ",concat_dir_and_file (home_dir, EDIT_CLIP_FILE)," -selection clipboard", NULL ); 
system (tmp); 
g_free(tmp);

...must have code

    // Work with X-buffer
    char *tmp;
    gchar *concat_result=concat_dir_and_file (home_dir, EDIT_CLIP_FILE);
    tmp = g_strconcat ("xclip -i ", concat_result, " -selection clipboard", NULL );
    system (tmp);
    g_free(tmp);
    g_free(concat_result);

I don't know, how make path file, but please insert this code correction.

@mc-butler
Copy link
Author

Changed by uchti (uchtii@….com) on Sep 11, 2009 at 11:13 UTC

editcmd.c xclip patch for 4.7.0-pre2

@mc-butler
Copy link
Author

Changed by xintrea (xintrea@….com) on Sep 11, 2009 at 19:06 UTC (comment 6.7)

Oops, solving for copy to X-buffer with "xclip" have any problem.

If system locale i.e. KOI-8R, and text file in other codepage (i.e. UTF-8), we select by Ctrl+T UTF-8 codepage. In "copy to X-buffer action", in cooledit.clip file putted text in UTF-8 codepade. Next, running command

xlib -i cooledit.clip

and in buffer inserting UTF-8 text. If paste from buffer this text into MC or into any text editor, we seen bad cyrillic symbol.

Solved this problem - convert cooledit.clip (before run xlib) from editor codepage to system codepage.

For write code, need known:

How get editor codepage as string, i.e. "UTF-8"?
How get system codepage as string, i.e. "KOI-8R"?

@mc-butler
Copy link
Author

Changed by iNode (@iNode) on Sep 12, 2009 at 6:50 UTC (comment 8)

Use enca, Luke.

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Sep 12, 2009 at 11:52 UTC (comment 7.9)

How get editor codepage as string, i.e. "UTF-8"?
How get system codepage as string, i.e. "KOI-8R"?

use "get_codepage_id (source_codepage)"

@mc-butler
Copy link
Author

Changed by xintrea (xintrea@….com) on Sep 12, 2009 at 19:53 UTC (comment 9.10)

Replying to angel_il:

How get editor codepage as string, i.e. "UTF-8"?
How get system codepage as string, i.e. "KOI-8R"?

use "get_codepage_id (source_codepage)"

Im jumble.

Index "source_codepage" - it is current editor codepage?
Index "display_codepage" - it is system codepage?

@mc-butler
Copy link
Author

Changed by xintrea (xintrea@….com) on Sep 13, 2009 at 20:01 UTC (comment 10.11)

This is bullshit. The official version of xclip uncorrect work with national (cyrillic) symbols.

Prooflink for russian people - http://habrahabr.ru/blogs/linux/48954/

If locale is KOI-8R, and in cooledit.clip put text in KOI-8R, then after command

xclip -i cooledit.clip -selection clipboard

in clipbord put text with bad cyrillic symbols.

What is to do?

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Sep 22, 2009 at 11:17 UTC (comment 12)

  • Milestone changed from 4.7.0-pre3 to 4.7.0-pre4

@mc-butler
Copy link
Author

Changed by slavazanko (@slavaz) on Oct 27, 2009 at 9:05 UTC (comment 13)

  • Milestone changed from 4.7.0-pre4 to 4.7

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Jun 9, 2010 at 19:59 UTC (comment 14)

  • Severity changed from no branch to on review
  • Type changed from task to enhancement
  • Owner set to angel_il
  • Keywords set to xclip, clipboard
  • Milestone changed from 4.7 to 4.7.3
  • Version set to master
  • Status changed from new to accepted

branch: 30_external_clipboard_utility
changeset: [a176c37b8460bd326f6dc7cabce576fccc894ded]

please review :)

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Jun 10, 2010 at 20:07 UTC (comment 15)

branch: 30_external_clipboard_utility (forced update)
changeset: [a5fd5ce88c130d6bc4b4061cfc8f4a4536e96ba1]

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jun 11, 2010 at 10:42 UTC (comment 16)

  • Votes set to andrew_b

@mc-butler
Copy link
Author

Changed by slavazanko (@slavaz) on Jun 11, 2010 at 12:07 UTC (comment 17)

  • Votes changed from andrew_b to andrew_b slavazanko
  • Severity changed from on review to approved

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Jun 11, 2010 at 16:51 UTC (comment 18)

  • Severity changed from approved to merged
  • Votes changed from andrew_b slavazanko to commited-master
  • Resolution set to fixed
  • Status changed from accepted to testing

Merged: [781706e]

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jun 22, 2010 at 17:56 UTC (comment 19)

  • Status changed from testing to closed
  • Description edited

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Jul 11, 2010 at 12:35 UTC (comment 20)

line 3987 in mc.1.in contains a copy&paste mistake (somewhat ironic in the context of this ticket :D).

i'm not sure why you chose to invoke an external tool and thus introduce an additional dependency for that. the x11 code to support that is pretty simple; you'd need to copy only a small part from xclip.

at the very least, the xclip calls should be in the default setup. otherwise it's as if the function wasn't there at all (many people miss it, but i don't think anyone would expect it to be actually there, "just needing configuration").

other than that, it works quite nicely, it seems. ;)

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Jul 11, 2010 at 14:04 UTC (comment 21)

  • Cc set to zaytsev

A bundled "brand new" keymap is on the way. I hope it will make it into master. One day. In what concerns xclip it's more tricky: one needs time and competence to implement this.

Line 3987 is .I xterm_mode. Hmmm?

Patches welcome.

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Jul 11, 2010 at 14:34 UTC (comment 21.22)

Replying to zaytsev:

A bundled "brand new" keymap is on the way.

noooo, *don't* add separate key bindings for that! it should work transparently as it does now. it should just be there by default.

Line 3987 is .I xterm_mode. Hmmm?

i meant in the commit that went in (781706...).

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Jul 11, 2010 at 15:01 UTC (comment 23)

  • Milestone changed from 4.7.3 to 4.7.4
  • Severity changed from merged to on review
  • Votes commited-master deleted
  • Status changed from closed to reopened
  • Resolution fixed deleted

Damn it, damned damn!

Branch: 30_typo_fixup (parent: master)
Changeset: [1b8278da2adf33f01d2dbdf786dc010f9eaf5f67] .

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Jul 11, 2010 at 15:03 UTC (comment 24)

The keymap is not going to be added just for that. It will encompass all the bindings for the new features, that break old behavior.

Right now, I don't see how one can make this working transparently by default without breaking old behavior and dependency on xclip doesn't make things any easier.

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Jul 11, 2010 at 15:11 UTC (comment 25)

you're right, the non-cua key bindings should not be affected. i even implied that myself in the original submission. :)

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 11, 2010 at 15:22 UTC (comment 26)

  • Votes set to andrew_b

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Jul 11, 2010 at 15:30 UTC (comment 27)

  • Severity changed from on review to approved
  • Votes changed from andrew_b to andrew_b angel_il

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Jul 12, 2010 at 10:48 UTC (comment 28)

  • Status changed from reopened to closed
  • Votes changed from andrew_b angel_il to committed-master
  • Severity changed from approved to merged
  • Resolution set to fixed

Merged: [ae65d8c] .

@mc-butler
Copy link
Author

Changed by beroal (stranger27@….in.ua) on Nov 7, 2010 at 9:08 UTC (comment 29)

Forget me if this is unrelated. There are "clipboard_store" and "clipboard_paste" options in ".mc/ini" file. What keys precisely invoke those commands in "mcedit"? I need to exchange with "Xorg" clipboard, but "mcedit" runs in a text console (i.e. Ctrl+F1 in Linux).

Also there are, I guess, mistakes in man pages:

"clipboard_store This variable contains path (with options) to the external clipboard utility like 'xclip' to read text into X selection from file." --- What file? Perhaps stdin?

"clipboard_paste This variable contains path (with options) to the external clipboard utility like 'xclip' to print the selection to standard out. For example:
clipboard_store=xclip -o" --- Example is unrelated.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Nov 7, 2010 at 13:16 UTC (comment 29.30)

Replying to beroal:

What keys precisely invoke those commands in "mcedit"?

By default, that are common shortcuts ctrl-ins, shift-ins, shift-del. You can redefined it in keymap file

[editor]
EditXStore = ctrl-insert
EditXPaste = shift-insert
EditXCut = shift-delete

"clipboard_store This variable contains path (with options) to the external clipboard utility like 'xclip' to read text into X selection from file." --- What file?

File that is loaded in mcedit.

"clipboard_paste This variable contains path (with options) to the external clipboard utility like 'xclip' to print the selection to standard out. For example:
clipboard_store=xclip -o" --- Example is unrelated.

What is unrelated? xclip prints selection to the its standard out. xclip's stdout is read by mc.

@mc-butler
Copy link
Author

Changed by beroal (stranger27@….in.ua) on Dec 15, 2010 at 9:46 UTC (comment 30.31)

Replying to andrew_b:

Replying to beroal:

"clipboard_store This variable contains path (with options) to the external clipboard utility like 'xclip' to read text into X selection from file." --- What file?

File that is loaded in mcedit.

Excerpt from "man xclip":

      -i, -in
              read text into X selection from standard input or files (default)

Does "mc" gives the name of that file to the "clipboard_store" command as argument? Or sends text to "stdin" of the process of the "clipboard_store" command?

"clipboard_paste This variable contains path (with options) to the external clipboard utility like 'xclip' to print the selection to standard out. For example:
clipboard_store=xclip -o" --- Example is unrelated.

What is unrelated? xclip prints selection to the its standard out. xclip's stdout is read by mc.

I did not expect that it would be hard to explain. When you write the example for "clipboard_paste", using "clipboard_store" in the example looks meaningless!

Please do not explain here, just fix the man pages.

@mc-butler
Copy link
Author

Changed by beroal (stranger27@….in.ua) on Dec 15, 2010 at 9:57 UTC (comment 30.32)

Replying to andrew_b:

Replying to beroal:

What keys precisely invoke those commands in "mcedit"?

By default, that are common shortcuts ctrl-ins, shift-ins, shift-del. You can redefined it in keymap file

[editor]
EditXStore = ctrl-insert
EditXPaste = shift-insert
EditXCut = shift-delete

So, this keys coincide with those that works with "~/.mc/cedit/cooledit.clip". If I start "mc" with "DISPLAY" variable, should it use "~/.mc/cedit/cooledit.clip" or the Xorg server clipboard?

@mc-butler
Copy link
Author

Changed by angel_il (@ilia-maslakov) on Dec 15, 2010 at 20:59 UTC (comment 32.33)

Replying to beroal:

Replying to andrew_b:

Replying to beroal:

What keys precisely invoke those commands in "mcedit"?

By default, that are common shortcuts ctrl-ins, shift-ins, shift-del. You can redefined it in keymap file

[editor]
EditXStore = ctrl-insert
EditXPaste = shift-insert
EditXCut = shift-delete

So, this keys coincide with those that works with "~/.mc/cedit/cooledit.clip". If I start "mc" with "DISPLAY" variable, should it use "~/.mc/cedit/cooledit.clip" or the Xorg server clipboard?

after you start action EditXStore (ctrl-insert pressed) mc do next steps:
1) write current selection into ~/.mc/cedit/cooledit.clip
2) test DISPLAY
3) get value of clipboard_store (for example "xclip -o")
4) build executable string $clipboard_store + $home_dir + $EDIT_CLIP_FILE + " 2>/dev/null"
in this case "xclip -o" + " " + "/home/username/.mc/cedit/cooledit.clip" + " 2>/dev/null"
5) execute this

for more detail see

...
gboolean
copy_file_to_ext_clip (void)
{
    char *tmp, *cmd;
    int res = 0;
    const char *d = getenv ("DISPLAY");

    if (d == NULL || clipboard_store_path == NULL || clipboard_store_path[0] == '\0')
        return FALSE;

    tmp = concat_dir_and_file (home_dir, EDIT_CLIP_FILE);
    cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);

    if (cmd != NULL)
        res = my_system (EXECUTE_AS_SHELL, shell, cmd);

    g_free (cmd);
    g_free (tmp);
    return TRUE;
}
...

PS: if you understood my explanation please send their corrections to the 'man'.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Sep 27, 2013 at 9:41 UTC (comment 34)

Ticket #3081 has been marked as a duplicate of this ticket.

@mc-butler
Copy link
Author

Changed by pfalcon (pmiscml@….com) on Sep 27, 2013 at 17:29 UTC (comment 35)

  • Branch state set to no branch

I don't want to reopen this very old ticket: granted, it was implemented, that can't be challenged. But I have some proposals how to enhance functionality, so I opened new bug #3083.

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Jan 11, 2014 at 15:56 UTC (comment 36)

  • Reporter changed from slavazanko to ossi
  • Description edited

@mc-butler
Copy link
Author

Changed by ossi (@ossilator) on Jan 11, 2014 at 15:58 UTC (comment 37)

  • Description edited

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jan 12, 2014 at 7:25 UTC (comment 38)

  • Branch state changed from no branch to merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: mcedit mcedit, the built-in text editor prio: low Minor problem or easily worked around
Development

No branches or pull requests

1 participant