This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 185483 - Internal terminal console should not intercept NB debugging hotkeys like F7 and F8
Summary: Internal terminal console should not intercept NB debugging hotkeys like F7 a...
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Terminalemulator (show other bugs)
Version: 6.x
Hardware: PC All
: P3 normal (vote)
Assignee: Egor Ushakov
URL:
Keywords:
: 30564 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-05 08:37 UTC by Alexander Pepin
Modified: 2011-05-21 08:49 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pepin 2010-05-05 08:37:09 UTC
This bug is a replica of CR 6657950("dbx console should not intercept NB debugging hotkeys like F7 and F8") as now it should be fixed in NB.
Steps to reproduce:
- create any sample e.g. Quote
- set Internal terminal as a Console type
- do Step into
- press F8 (Step Over), step over is performed
- set focus on Internal terminal tab (click mouse on Quote(Debug) tab in Output window)
- press F8 (Step Over)
Result: Nothing happens.
Comment 1 ivan 2010-05-08 07:13:42 UTC
*** Bug 30564 has been marked as a duplicate of this bug. ***
Comment 2 ivan 2010-05-10 20:41:40 UTC
Well, it turns out this isn't that easy to do.
The terminals fundamental job is to pass all keystrokes on to the underlying
application. Therefore it consumes all keyboard events.

However, since it's early days Term has had a facility to allow specifying 
which Keystrokes to not consume so they could be intercepted by other
mechanisms. So, for example one can do
    passKeystrokes.add(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0));
    term.setKeyStrokeSet((HashSet) passKeystrokes);
(This was working poorly/misunderstood. See bug #185756)
So it should simply be a matter of passing all of NB's global keystrokes
to Term via this setKeyStrokeSet.

But it's not that simple.

1) It turns out the global NB keymap is not available. One can Lookup
   Keymap and get it's implementation, NbKeymap. But NbKeymap doesn't
   implement getBoundKeyStrokes() and many other methods of Keymap.
   It seems to only provide a context-specific keystroke to action map.

   It only minimally implements Lookup so one cannot get notifications
   via Lookup.Result either

   Maybe there's another way but I haven't discovered it yet.

2) Suppose we could get the whole Keymap and tell Term about it, but do
   we want to? What if there's some sequence that a vi or emacs or 
   midnight-commander running under the terminal needs to see?
   The fancy solution would be to provide a UI for alllowing the user 
   to choose what to pass thru and what not.
   I believe Ernie Rael's vi plugin ran into a similar problem and vi
   settings have such tables.
   There's prolly not enough time to create such a table and it's UI for 
   6.9.

I _could_ hard-code some common and important accelerators directly into 
Terminal, but I'm not very comfortable with hard-coding things.
Or one can create a table managed by terminal options which has no knowledge
of NB's default keymap and just allows users to control which keystrokes
Term shouldn't consume.
Comment 3 Jesse Glick 2010-05-10 21:49:28 UTC
There is no way of knowing which keystrokes an application run in term might actually need; surely it would be common for these to overlap with NB global accelerators. Recommend just having some simple way for the user to pass through keys to the container. For example, VirtualBox lets you define a host key (I use Right Shift) after which the container receives keystrokes. More to the point, Emacs does this in its M-x terminal-emulator mode.
Comment 4 ivan 2010-05-10 23:02:24 UTC
JG: There is no way of knowing which keystrokes an application run in term might
JG: actually need;

indeed.

JG: For example, VirtualBox lets you define a host
JG: key (I use Right Shift) after which the container receives keystrokes.

You mean as a mode or a prefix/escape?
In either case it would sort-of defeat the purpose of accelerators.
The bug summary talks about stepIn/StepOver ... who wants to escape those?
Comment 5 Jesse Glick 2010-05-11 00:58:08 UTC
(In reply to comment #4)
> You mean as a mode or a prefix/escape?

Yes, probably as a mode.

> In either case it would sort-of defeat the purpose of accelerators.
> The bug summary talks about stepIn/StepOver ... who wants to escape those?

I don't think e.g. Right-Shift F8 is much worse than F8, especially if the escape were truly modal (so you would only need to press it once after having used term for a while). Or just have some key sequence in term which makes it lose focus.
Comment 6 Alexander Pepin 2010-08-12 14:55:42 UTC
should be fixed in 6.10
Comment 7 Egor Ushakov 2011-05-06 16:04:30 UTC
fixed in:
http://hg.netbeans.org/cnd-main/rev/6b527d398a1e

now we use _global_ keymap for all keystrokes in the terminal,
there is an option in global terminal options to disable that.
Comment 8 Quality Engineering 2011-05-07 05:34:03 UTC
Integrated into 'main-golden', will be available in build *201105070000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/6b527d398a1e
User: Egor Ushakov <gorrus@netbeans.org>
Log: fixed #185483 (Handle global shortcuts in the terminal)
Comment 9 Egor Ushakov 2011-05-19 18:00:14 UTC
new implementation in:
http://hg.netbeans.org/releases/rev/0baca1c47319
actions allowed in the terminal are now specified in a folder:
Terminal/Shortcuts
any developer can add/remove actions from there.
I expect someone to create a nice GUI plugin for this someday.
As for now we have only debug/run main project and debugger step into/over actions specified.
Comment 10 Egor Ushakov 2011-05-19 18:06:51 UTC
also I expect developers to register actions if they want them to work in the terminal in their module's layer files.
Comment 11 Egor Ushakov 2011-05-20 08:20:24 UTC
also implemented a listener to monitor shortcuts folder changes:
http://hg.netbeans.org/releases/rev/219a9cf3a991
Comment 12 Quality Engineering 2011-05-20 08:55:07 UTC
Integrated into 'main-golden', will be available in build *201105200400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4849d363bcee
User: Egor Ushakov <gorrus@netbeans.org>
Log: fixed #185483 (global shortcuts in the terminal) - predefined actions
(transplanted from 0baca1c473195048b39f80d3e605160895953799)
Comment 13 Quality Engineering 2011-05-21 08:49:13 UTC
Integrated into 'main-golden', will be available in build *201105210400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/d5fe262a8315
User: Egor Ushakov <gorrus@netbeans.org>
Log: fixed #185483 (global shortcuts in the terminal) - listen to the shortcuts folder changes
(transplanted from 219a9cf3a99186d5d2ceba1a80e3fa3d0efb6299)