[PATCH] space on prompt bugfix
- From: Jindrich Novy <jnovy redhat com>
- To: MC Devel <mc-devel gnome org>
- Subject: [PATCH] space on prompt bugfix
- Date: Mon, 21 Mar 2005 09:19:34 +0100
Hi mc-devel!
There's a bug I've been annoyed with for some time so I finally decided
to fix it.
To reproduce:
1. start mc
2. go to some directory where you see some further subdirectories
3. press space once or for more times -> spaces will appear in the
command prompt
4. try to go to some subdirectory by pressing enter on it or press enter
on any *.c, *.mp3 file.
Results:
You're unable to change a directory until you delete all spaces typed on
command prompt and mc does nothing while you're pressing Enter.
Furthermore you're unable to launch any application by tapping enter on
*.c, *.mp3 files, etc.
I did two patches to fix it so that you can decide which one is better
commit candidate.
Patch1:
Allows an user to type leading spaces on the command prompt, but when
enter is pressed, it tests whether the user typed at least something
except spaces. In case it finds only spaces, it deletes them from the
command prompt and let the enter be further processed.
Patch2:
Doesn't let the user to type leading spaces if he didn't write a non-
space letter already.
Note that both the patches also contain fix for a redundant strlen ()
call.
Cheers,
Jindrich
--
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
--- mc-4.6.1-pre3/src/main.c.jn 2005-03-19 15:55:40.000000000 +0100
+++ mc-4.6.1-pre3/src/main.c 2005-03-19 17:04:10.000000000 +0100
@@ -1490,9 +1490,14 @@ midnight_callback (struct Dlg_head *h, d
if (parm == '\t')
free_completions (cmdline);
- if (parm == '\n' && cmdline->buffer[0]) {
- send_message ((Widget *) cmdline, WIDGET_KEY, parm);
- return MSG_HANDLED;
+ if (parm == '\n') {
+ for (i = 0; cmdline->buffer[i] && cmdline->buffer[i] == ' '; i++);
+ if (cmdline->buffer[i]) {
+ send_message ((Widget *) cmdline, WIDGET_KEY, parm);
+ return MSG_HANDLED;
+ }
+ stuff (cmdline, "", 0);
+ cmdline->point = 0;
}
/* Ctrl-Enter and Alt-Enter */
@@ -1527,7 +1532,7 @@ midnight_callback (struct Dlg_head *h, d
reverse_selection_cmd ();
return MSG_HANDLED;
}
- } else if (!command_prompt || !strlen (cmdline->buffer)) {
+ } else if (!command_prompt || !cmdline->buffer[0]) {
/* Special treatement '+', '-', '\', '*' only when this is
* first char on input line
*/
--- mc-4.6.1-pre3/src/main.c.jn 2005-03-19 15:55:40.000000000 +0100
+++ mc-4.6.1-pre3/src/main.c 2005-03-19 18:09:48.000000000 +0100
@@ -1482,6 +1482,11 @@ midnight_callback (struct Dlg_head *h, d
if (the_menubar->active)
return MSG_NOT_HANDLED;
+ if (parm == ' ') {
+ if ( !cmdline->buffer[0] )
+ return MSG_HANDLED;
+ }
+
if (parm == KEY_F (10)) {
quit_cmd ();
return MSG_HANDLED;
@@ -1527,7 +1532,7 @@ midnight_callback (struct Dlg_head *h, d
reverse_selection_cmd ();
return MSG_HANDLED;
}
- } else if (!command_prompt || !strlen (cmdline->buffer)) {
+ } else if (!command_prompt || !cmdline->buffer[0]) {
/* Special treatement '+', '-', '\', '*' only when this is
* first char on input line
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]