mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-09 23:25:43 +01:00
fix egregious programming sloppiness in strip_whitespace_edges
git-svn-id: svn://localhost/ardour2/trunk@1121 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2dafaad193
commit
e8a2bf9b49
2 changed files with 46 additions and 0 deletions
|
|
@ -359,12 +359,25 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
|
|||
GtkWidget* focus = gtk_window_get_focus (win);
|
||||
bool special_handling_of_unmodified_accelerators = false;
|
||||
|
||||
#undef DEBUG_ACCELERATOR_HANDLING
|
||||
#ifdef DEBUG_ACCELERATOR_HANDLING
|
||||
bool debug = (getenv ("ARDOUR_DEBUG_ACCELERATOR_HANDLING") != 0);
|
||||
#endif
|
||||
|
||||
if (focus) {
|
||||
if (GTK_IS_ENTRY(focus)) {
|
||||
special_handling_of_unmodified_accelerators = true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ACCELERATOR_HANDLING
|
||||
if (debug) {
|
||||
cerr << "Key event: code = " << ev->keyval << " state = " << hex << ev->state << dec << " focus is an entry ? "
|
||||
<< special_handling_of_unmodified_accelerators
|
||||
<< endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This exists to allow us to override the way GTK handles
|
||||
key events. The normal sequence is:
|
||||
|
||||
|
|
@ -441,20 +454,40 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
|
|||
|
||||
/* no special handling or modifiers in effect: accelerate first */
|
||||
|
||||
#ifdef DEBUG_ACCELERATOR_HANDLING
|
||||
if (debug) {
|
||||
cerr << "\tactivate, then propagate\n";
|
||||
}
|
||||
#endif
|
||||
if (!gtk_window_activate_key (win, ev)) {
|
||||
return gtk_window_propagate_key_event (win, ev);
|
||||
} else {
|
||||
#ifdef DEBUG_ACCELERATOR_HANDLING
|
||||
if (debug) {
|
||||
cerr << "\tnot handled\n";
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* no modifiers, propagate first */
|
||||
|
||||
#ifdef DEBUG_ACCELERATOR_HANDLING
|
||||
if (debug) {
|
||||
cerr << "\tactivate, then propagate\n";
|
||||
}
|
||||
#endif
|
||||
if (!gtk_window_propagate_key_event (win, ev)) {
|
||||
return gtk_window_activate_key (win, ev);
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_ACCELERATOR_HANDLING
|
||||
if (debug) {
|
||||
cerr << "\tnot handled\n";
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ strip_whitespace_edges (string& str)
|
|||
|
||||
len = str.length();
|
||||
|
||||
if (len == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* strip front */
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
|
|
@ -19,12 +23,21 @@ strip_whitespace_edges (string& str)
|
|||
}
|
||||
}
|
||||
|
||||
if (i == len) {
|
||||
/* its all whitespace, not much we can do */
|
||||
return;
|
||||
}
|
||||
|
||||
/* strip back */
|
||||
|
||||
if (len > 1) {
|
||||
|
||||
s = i;
|
||||
i = len - 1;
|
||||
|
||||
if (s == i) {
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
if (isgraph (str[i]) || i == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue