Chris Siebenmann
2012-02-07 20:41:22 UTC
I feel like I'm missing some important bits about how fvwm handles
functions.
I'm trying to write a function that's fed a window name and has
following goals. First, it only operates on terminal windows.
Then:
- if no (terminal) window by that name exists, it should do nothing.
- if the currently selected/focused window has that name (and is a terminal
window), it should do nothing.
- otherwise, it should deiconify, focus, and raise the window, then
move the pointer to be inside the window.
My current version is:
AddToFunc ToWindow
+ I Current ("XTerm|9term|Gnome-terminal", "$0") Break
+ I Next ("XTerm|9term|Gnome-terminal", "$0") Iconify False
+ I Next ("XTerm|9term|Gnome-terminal", "$0") Focus
+ I Next ("XTerm|9term|Gnome-terminal", "$0") Raise
+ I Next ("XTerm|9term|Gnome-terminal", "$0") WarpToWindow 80 5
This works but seems unnecessarily repetitive (actually I'm suddenly
not convinced that it does nothing if the current window is a terminal
window called $0). So I thought I could rewrite it like this (with
comments about the logic):
AddToFunc ToWindow
# do nothing if current window is called $0
+ I Current ("XTerm|9term|Gnome-terminal", "$0") Break
+ I Next ("XTerm|9term|Gnome-terminal", "$0") Focus
# if no window is called $0, this stops; otherwise Focus has
# made that window the current window.
+ I TestRc (NoMatch) Break
# do the rest of the work
+ I Iconify False
+ I Raise
+ I WarpToWindow 80 5
However, this doesn't work if no such window actually exists; before
anything from the function seems to execute (even an 'Echo' statement
inserted as the first command in the function), the mouse cursor changes
to the 'select a window' cursor. Clearly I'm missing something both
about how fvwm executes functions and how it selects windows and handles
conditional commands.
Do I need to make all commands conditional in this function in order
to have things work right, by putting plain 'Current ' in front of the
last three lines? (A version with this change seems to do nothing if
there's no terminal window by that name, but I feel I'm just sort of
writing code by superstition instead of actual understanding at this
point.)
Thanks in advance.
- cks
functions.
I'm trying to write a function that's fed a window name and has
following goals. First, it only operates on terminal windows.
Then:
- if no (terminal) window by that name exists, it should do nothing.
- if the currently selected/focused window has that name (and is a terminal
window), it should do nothing.
- otherwise, it should deiconify, focus, and raise the window, then
move the pointer to be inside the window.
My current version is:
AddToFunc ToWindow
+ I Current ("XTerm|9term|Gnome-terminal", "$0") Break
+ I Next ("XTerm|9term|Gnome-terminal", "$0") Iconify False
+ I Next ("XTerm|9term|Gnome-terminal", "$0") Focus
+ I Next ("XTerm|9term|Gnome-terminal", "$0") Raise
+ I Next ("XTerm|9term|Gnome-terminal", "$0") WarpToWindow 80 5
This works but seems unnecessarily repetitive (actually I'm suddenly
not convinced that it does nothing if the current window is a terminal
window called $0). So I thought I could rewrite it like this (with
comments about the logic):
AddToFunc ToWindow
# do nothing if current window is called $0
+ I Current ("XTerm|9term|Gnome-terminal", "$0") Break
+ I Next ("XTerm|9term|Gnome-terminal", "$0") Focus
# if no window is called $0, this stops; otherwise Focus has
# made that window the current window.
+ I TestRc (NoMatch) Break
# do the rest of the work
+ I Iconify False
+ I Raise
+ I WarpToWindow 80 5
However, this doesn't work if no such window actually exists; before
anything from the function seems to execute (even an 'Echo' statement
inserted as the first command in the function), the mouse cursor changes
to the 'select a window' cursor. Clearly I'm missing something both
about how fvwm executes functions and how it selects windows and handles
conditional commands.
Do I need to make all commands conditional in this function in order
to have things work right, by putting plain 'Current ' in front of the
last three lines? (A version with this change seems to do nothing if
there's no terminal window by that name, but I feel I'm just sort of
writing code by superstition instead of actual understanding at this
point.)
Thanks in advance.
- cks