Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mapped CTRL-C doesn't work in gvim due to focus out/in events confusing ctrl_c_interrupts. #12

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?

1. Run Gnome 2 desktop environment.

2. In Gnome, System menu -> Preferences -> Assistive Technologies, pops up a 
window, click "Mouse Accessibility" button, pops up a window, click "General" 
tab, enable "Show position of pointer when the Control key is pressed".

3. In .vimrc, map C-C to something (e.g. use mswin.vim to map C-C to copy)

4. Run gvim

5. Press C-C (e.g if in mswin mode, select some text (e.g. Shift-DownArrow a 
couple of times then press Ctrl-C)

What is the expected output?

Selected text is copied. Selected text stays highlighted.

What do you see instead?

No text is copied (C-V won't paste it). Selected text gets unhighlighted; 
visual mode is exited.

What version of the product are you using? On what operating system?

64-bit Ubuntu Natty, Ubuntu-packaged gvim (vim 7.3.35). Also happens with 
7.3.219 built from latest Hg source.

Please provide any additional information below.

This can be fixed (or perhaps just hacked around) by editing gui_gtk_x11.c near 
the end of function key_press_event() from:

    if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
           || (string[0] == intr_char && intr_char != Ctrl_C)))
    {
    trash_input_buf();
    got_int = TRUE;
    }

to:

    if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts && !mapped_ctrl_c)
           || (string[0] == intr_char && intr_char != Ctrl_C)))
    {
    trash_input_buf();
    got_int = TRUE;
    }

But a better solution probably relies on correctly setting ctrl_c_interrupts to 
WAR the issue described below.

Background:

If the Gnome option "show mouse pointer position" is not set, ctrl_c_interrupts 
is false when the C-C keypress is received, and everything works.

However, due to the extra keypress events processed when "show mouse pointer 
position" is enabled, ctrl_c_interrupts gets set back to true, and C-C triggers 
trash_input_buf() etc. The extra keypress events from the Control key being 
pressed are injected from focus lost/gained events, which IIRC get injected 
from gui.c function gui_focus_change().

Original issue reported on code.google.com by [email protected] on 16 Jun 2011 at 3:19

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions