i think this breaks single-clicking on a tab to switch tab. only
components that don't listen for mouse events themselves let mouse events
pass through, so if you call addMouseListener, you can't rely on the
JTabbedPane to just do it for you.
i think the easiest fix is probably to call addMouseListener in
TerminatorTabbedPane.addTab to add a listener that calls
setSelectedComponent(c) on clicks.
(i'll look at the close buttons when we get the double-click stuff
committed, so it's probably easiest to split this into two patches. i
think the double-click part should be fine once you've simulated the usual
click-through.)
--
Elliott Hughes, http://www.jessies.org/~enh/
the patch ("diff -u" again the last revision) for the close button is attached.
Other subject: when I close a tab, I get always this exception:
java.io.IOException: read(26, buffer, 0, 8192) failed: Input/output error
at terminator.terminal.PtyProcess$PtyInputStream.read(PtyProcess.java:31)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at terminator.terminal.TerminalControl$ReaderRunnable.run(TerminalControl.java:152)
at java.lang.Thread.run(Thread.java:619)
Costantino
===================================================================
--- src/terminator/TerminatorTabbedPane.java (revision 1554)
+++ src/terminator/TerminatorTabbedPane.java (working copy)
@@ -178,9 +178,41 @@
terminalPane.getControl().addChangeListener(this);
add(label, BorderLayout.CENTER);
- add(outputSpinner, BorderLayout.EAST);
+ add(outputSpinner, BorderLayout.WEST);
+
+ addCloseButton();
it's easier to understand the layout if all the calls to "add" are
together. we tend to use something more like add(makeX()...) instead.
}
+ private void addCloseButton() {
+ final Icon closeXIcon0 = new
ImageIcon(getClass().getResource("/terminator/closeicon0.gif"));
+ final Icon closeXIcon1 = new
ImageIcon(getClass().getResource("/terminator/closeicon1.gif"));
we keep resources in the lib directory. but if all we want is GNOME icons,
we can get those via GnomeStockIcon.
of course, since we also support Mac OS and Windows, we need to do
something reasonable for them too.
+ Dimension closeButtonSize = new
Dimension(closeXIcon0.getIconWidth() + 6, closeXIcon0.getIconHeight() +
4);
+ final JButton closeButton = new JButton(closeXIcon0);
+ closeButton.setFocusable(false);
+ closeButton.setContentAreaFilled(false);
+ closeButton.setPreferredSize(closeButtonSize);
+ add(closeButton, BorderLayout.EAST);
+
+ closeButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ terminalPane.doCheckedCloseAction();
+ }
+ });
+
+ closeButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ closeButton.setIcon(closeXIcon1);
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ closeButton.setIcon(closeXIcon0);
+ }
+ });
see JButton.setRolloverEnabled and related methods.
+ }
+
attached is something that makes these changes and goes a little further
towards doing the right thing on Linux. i haven't tested on Mac OS or
Windows, though.
> Other subject: when I close a tab, I get always this exception:
> java.io.IOException: read(26, buffer, 0, 8192) failed: Input/output error
> at terminator.terminal.PtyProcess$PtyInputStream.read(PtyProcess.java:31)
> at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264) at
> sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) at
> java.io.InputStreamReader.read(InputStreamReader.java:167)
> at
> terminator.terminal.TerminalControl$ReaderRunnable.run(TerminalControl.ja
> va:152)
> at java.lang.Thread.run(Thread.java:619)
yeah, we don't really shut things down in an orderly fashion.
i don't understand: the BorderLayout's hgap is already set to 4 in my patch.
> Unfortunately I've no chance to test under Mac Os.
it doesn't look very good. (nor did the existing activity indicators.) we
could really do with a more Safari-like JTabbedPane on Mac OS. sadly,
neither Quaqua nor "Mac Widgets for Java" has any such thing.
i'll wait and see what mad says about how it looks on Windows.
> Sometimes the Spinner remains visibile also if nothing is done (it
> freezes)... for example when you open multiple tabs very fast with "alt+t"
that's always been the case though. (and i think it's telling the truth:
the prompt has been drawn, and you haven't seen it.)
you're right, but I don't know why, they are higher than in
gnome-terminal or Firefox (see attached screenshot)
I've done some tries, and it seems that hgap has no effect in this case.
Anyway for me it isn't very important because I use the Nimbus LAF
(Gtk Laf looks still ungly... I hope it will be better in the next
java releases).
ah, the screenshot's useful: you mean _taller_ rather than higher. (yeah,
i know, "alta" works fine for both purposes, but it's too late to fix
English!)
this has been annoying me too, but it's unrelated to this change. i
haven't found any way to fix it from our code. i've tried different fonts
and i've tried fiddling with borders, but the GTK LAF has a bad habit of
ignoring most of the stuff you set and just doing its own thing anyway.
(try using setBackground on a JTextField, for example, and watch it have
absolutely no effect.)
actually, FatBits shows that Evergreen's tabs are one pixel shorter than
Terminator's (even without this patch), so it's possible we might be able
to win one pixel back, even if we can't get the others.
> Anyway for me it isn't very important because I use the Nimbus LAF
> (Gtk Laf looks still ungly... I hope it will be better in the next
> java releases).
it's the same in the early access releases of JDK7, and in OpenJDK.
i've signed the OpenJDK SCA because i'd like to have a go at fixing some
of these GTK LAF problems. the guy i was talking to is on holiday at the
moment, or i'd be showing him patches to JColorChooser that make it look
more like the real thing. not a very useful place to start, but an easy
place to start.
> i'll wait and see what mad says about how it looks on Windows.
The grey color makes the control look disabled when it isn't. Firefox's close icon for a tab, for me, is a white X on a background that's red when it's the topmost tab and grey otherwise, unless rolled over, in which case it appears like the topmost tab. The background gets brighter on rollover, much like whatever window manager Gnome/Debian inflicts me with. Other windows use a black X on a darker (but still only mid) grey background. Some of the more modern (by which you don't want to assume any reasonable definition of modern - I'm still running Windows 2000) Office apps that I have installed use a lighter grey background, which goes darker on roll-over. I don't think Windows users are a fussy lot, and I'm certainly not, so most of the previous description is just for completeness, but the current icon does look disabled.
-----Original Message-----
From: terminat...@googlegroups.com
[mailto:terminat...@googlegroups.com]
On Behalf Of Elliott Hughes
Sent: Wednesday, June 17, 2009 22:02
To: terminat...@googlegroups.com
Subject: [terminator-users] Re: Patch for tab with X to close
On Wed, June 17, 2009 04:25, Costantino Cerbo wrote:
> Ok, I've tested your modified path also with the Laf Nimbus und it's
> okay (on rollover it becames red). With GTK Laf is almost like Firefox
> (with border), but I find it a
> little bit too hight (therefore I've se hgap = 4)
i don't understand: the BorderLayout's hgap is already set to 4 in my patch.
> Unfortunately I've no chance to test under Mac Os.
it doesn't look very good. (nor did the existing activity indicators.) we
could really do with a more Safari-like JTabbedPane on Mac OS. sadly,
neither Quaqua nor "Mac Widgets for Java" has any such thing.
i'll wait and see what mad says about how it looks on Windows.
> Sometimes the Spinner remains visibile also if nothing is done (it
> freezes)... for example when you open multiple tabs very fast with "alt+t"
that's always been the case though. (and i think it's telling the truth:
the prompt has been drawn, and you haven't seen it.)
Regarding the "almost" invisible X, I find it not so bad, at least with Nimbus.
An other example is of course provided by Eclipse: there the X appears
only on mouse rollover, otherwise it isn't visible,
Ok, it's fine!
I think you should also update the "Multiple Tabs" screenshots on the
web site and also say that double clicking on tabs allows to change
their name.
Cheers,
Costantino
Yes, good idea, I should also do it (helping fixing the GTK LAF).
I find particular annoying that the font is too thin respect to the
true GTK font (see again the screenshot that compare the tab size
between Terminator and Gnome-Terminal)
yeah, one of these days we should take some new screenshots.
> and also say that double clicking on tabs allows to change their
> name.
i've mentioned that double-clicking opens the info dialog in the
(newly-created and still pretty empty) manual, but i'm not sure we want to
recommend people use the info dialog to change a tab's name; the intention
is that they've set PS1 so that it updates the tab/window title as they go
about their business.
Relevant section:
> 1. View title isn't working or only works in some applications (e.g. vim).
>
> You'll need to teach your bash start-up scripts about the 'terminator'
> terminal
> type. E.g. on Ubuntu edit ~/.bashrc and add '|terminator' (no quotes)
> to the
> block below after 'rxvt*'.
>
> # If this is an xterm set the title to user@host:dir
> case "$TERM" in
> xterm*|rxvt*)
> PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:
> ${PWD/$HOME/~}\007"'
> ;;
> *)
> ;;
> esac
>
> See also jessies.org FAQ entry.
I don't claim to know a lot about this but I observed the above worked
and it seemed a lot simpler than the current jessies FAQ entry. I just
checked on a Fedora system and they also have a case on $TERM in .bashrc
that can be similarly modified.
Cheers,
Matt.
that's because the FAQ entry is answering a slightly more general
question, and trying to leave you with some reusable pieces. but if Ubuntu
comes with a default .bashrc (i didn't know; i probably copied my own over
it without even looking) it might be worth us explaining what changes to
make. likewise Cygwin and Mac OS.
i have extra hacks in my work prompt setup; i look for the GNOME
session-id environment variable, and if i see it, i don't put the hostname
in (since i'm on the console of some machine). i also chop off the boring
part of the domain name, since i remember which company i work for and
would like those 16 characters back.
--elliott
> I just
> checked on a Fedora system and they also have a case on $TERM in .bashrc
> that can be similarly modified.
>
> Cheers,
>
>
> Matt.
--
Elliott Hughes, http://www.jessies.org/~enh/