Re: xterm_title patch 898

2003-01-14 Thread Tomas Styblo
* Adam Byrtek 'alpha' [EMAIL PROTECTED] [Sun, 12 Jan 2003]:
 On Sun, Jan 05, 2003 at 05:39:54AM +0100, Tomas Styblo wrote:
  In my humble opinion the restore does not work over network
  because the implementation is fundamentally broken.
 Yes, I fully agree. It was just a dirty hack to start with. I was
 thinking about this issue during Christmas vacation and I see no easy
 way to implement this in a clean and compatibile way.

[SNIP]

 First of all we have to choose between blocking and non-blocking
 behaviour to read old xterm title. Blocking is bad - if one's xterm is
 broken and didn't respond, user can wait forever, which is
 unacceptable. Non-blocking is also bad - we have to set some arbitrary
 timeout to wait for response on slow links, but it is unacceptable to
 force user with broken xterm wait 5 seconds. And if the response
 arrives after the timeout, it clutters the screen.
 
 And no, TERM env variable IMO is not a reliable way to detect xterm
 capabilities.
 
 I see no good approach. I guess we could implement Tomas' patch as a
 additional option 'store/restore xterm title', which will be *turned
 off* by default. But I'm not sure if this feature is really so
 important. I personaly use shell to refresh title to cwd on every cd
 or execution.

My patch is bad. The delay seems to be unconditional on some
people's OSes.

I checked how vim sets and restores the title.

It uses a completely different approach.

It looks at environment variables WINDOWID and DISPLAY and 
connects to the X server using xlib. Then it gets and sets the 
title using the xlib functions XGetWMName and XSetWMName.

It works very well in my experience. But it may not work
remotely, when X forwarding is not enabled in ssh configuration.

Maybe we should consider using this approach to restore the title ?

 Yes, I think your plan (XTERM_TITLE variable) is good. It would be
 very hard to convince people, but I think you should try.

I already have the library to implement it ready. It does not take
care of restoring the title, though. I already got patches for
some popular terminal applications to use the library to set a
title. If you are interested in it, please contact me privately.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: xterm_title patch 898

2003-01-07 Thread Tomas Styblo
* Thomas Zajic [EMAIL PROTECTED] [Tue, 07 Jan 2003]:
 Now that's strange, because AFAICT it _does_ report the proper title, or
 at least mc is _somehow_ able to restore it upon exit. Do you have some
 fallback(s) in place to get the title, ie. something other than what you
 are trying to do within the 5 seconds?

Well maybe there is a bug in the code and I just can't see it, but
it works for me.

seen_esc = 0;
while (i  sizeof(title)  read(tty, ch, 1)  0) {

/* read and discard characters until we get the ESC character
   which starts the title response of the terminal */

if (seen_esc == 0) { 
if (ch == '\033') 
seen_esc = 1;
else
continue;
}   

/* This character terminates the title response
   according to the xterm control sequence specification.
   Stop reading - this should prevent the delay */
if (ch == '\x9c')  /* ST */
break;

/* append a character of the title response to the buffer */
title[i++] = ch;
}   


-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: xterm_title patch 898

2003-01-06 Thread Tomas Styblo
* Thomas Zajic [EMAIL PROTECTED] [Mon, 06 Jan 2003]:
 Seems to work fine so far, although it adds a noticable 5 second delay
 when starting mc, mc -v, or mcedit from the command line and/or as an
 external editor/viewer from Mutt/Slrn, both locally and remote. There
 is no such delay when invoking mcedit and mc -v by pressing F3/F4 from
 within mc, neither locally nor remote.

The delay should happen only when the terminal is not able to
report the title. What terminal emulator do you use ?

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: xterm ttle patch v898 v2

2003-01-06 Thread Tomas Styblo
* Tribhuvan [EMAIL PROTECTED] [Tue, 07 Jan 2003]:
 This is a modification of a patch Tomas Stylbo sent me 
 a couple of days ago.

I really think it's too error prone and that we rather should not
try to restore the title. The xterm title feature is by default
disabled so we can inform the user in the manual how to work
around it in the shell.

 4) added option for displaying user@host in title bar
   I still have to add explicit support for NATIVE_WIN32
   (ie: correct environment variables for USER and HOSTNAME)

It would be better not to count on presence of these variables.

If the USER variable is not set then the username should be
obtained from the passwd structure (getpwuid(getuid()).

You should also try the USERNAME variable.

If the HOSTNAME variable is not set then the hostname should be
obtained by calling the gethostname() function. But it's not
present on all platforms probably.

Also I'd prefer a generic solution to this problem. The user
should have the possibility to define the format of the title. I
already created some code that uses a new XTERM_TITLE variable for
this purpose. I plan to release it sometimes together with a
specification defining how the content of this variable should be
interpreted. The specification is not written yet, though.

Anyway, the small library routine together with a small test
program is attached to this message. It allows the user to define
format of the title using the env variable, like this:

XTERM_TITLE=%a: %r= mc: /home/trip

XTERM_TITLE=(%r) - %U  = (/home/trip) - MC

XTERM_TITLE=%a: %r (%u@%h) [%p] =

mc: /home/trip (trip@host) [1234]
  = pid

It would be nice if you could look at this code, make it compile
on solaris and use it as a base for the enhanced title
implementation. That way the title can be consistently implemented
in various terminal applications. The code is complete, tested,
but lacks the very important documentation yet.
 
 1) the problem on remote host is still not resolved
   (ie: store and restore - the title function works fine
on remote machines, but _restoring_ old title does not.
The delay on initialization of the store_xterm_title
is fine (though it could be reduced to a fraction of a second)

I really don't know where's the problem then, sorry. I thought
that the failure to restore the title was caused by too short
delay when we are trying to read the title from the terminal.

 I think it should be introduced in _restore_ when
 mc is exiting/cleaning up. 

That's impossible, we must read the original title before we
change it in any way. That means it must be done at the start.

 2)  I'd like to create a dialog box for these extra features, so
that while they are compiled in by default - they can be
switched on and off on-the-fly for buggy/cheap terminal
environments.
 
 Question for Thomas Stylbo: what platform are you testing on?

I am using Linux and FreeBSD, XFree 4.2.0.

 Will report back full testing results a little later

Please try just this. Login to the remote system and run this in
the shell:

echo -e \e[21t

Does it print the title ?

Does it work on your local system ?

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6



xterm-title.tar.gz
Description: GNU Zip compressed data


Re: a solution for high and dry xterm_title (long)

2003-01-05 Thread Tomas Styblo
.

If your system does not define the SA_INTERRUPT flag, then you can
try the following:

- Simply do not specify the SA_INTERRUPT flag in the
  sigaction.sa_flags field. By default non-terminating signal
  handlers should not restart system calls if you install them
  via sigaction.
 
- Try to call the BSD function:

siginterrupt(SIGALRM, 1);

  before the call to sigaction.

...

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: pre2 problem with gcc option

2003-01-04 Thread Tomas Styblo
* Pavel Roskin [EMAIL PROTECTED] [Thu, 02 Jan 2003]:
 Maybe this option breaks ABI compatibility - then it's
 not a bug.

Yes it breaks ABI compatibility.

[SNIP]

 When compiled with -mdouble-align, MC does not funtion
 correctly, namely all file sizes are displayed the same (some
 number like 16000G) and viewing, editing or anything else does
 not work (file empty etc.). It is specifically this option that
 causes the problem...I tracked it down by adding one option at a
 time and no problems until this one. Took it back out again...no
 problem.

gcc documentation says:

  -malign-double
  -mno-align-double

  Control whether GNU CC aligns double, long double, and
  long long variables on a two word boundary or a one word
  boundary. Aligning double variables on a two word boundary
  will produce code that runs somewhat faster on a `Pentium`
  at the expense of more memory.  WARNING: if you use the
  `-malign-double` switch, structures containing the above
  types will be aligned differently than the published
  application binary interface specifications for the 386. 

I think the problem happens when working with the st_size memeber 
of the stat structure. I suppose the off_t type is a typedef of
long long on that user's machine.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: xterm_title patch 898

2003-01-04 Thread Tomas Styblo
* Tribhuvan [EMAIL PROTECTED] [Sat, 04 Jan 2003]:
 Adam Byrtek 'alpha' wrote:
 It was recently discussed on this list, and I've made a patch to store
 and restore old title:
 I inserted the code as per above patch on 4.6.pre2 and tested:
 rxvt  - ok on localhost: no-restore on remote host
 gnome-terminal - same as rxvt
 dtterm - title changes but old_xterm_title goes to stdout (comand line 
 in mc) and causes unpredictable bhvr
this is from the store_xterm_title function (this is on 
 localhost, so didn't bother testing on remote)
 xterm  - ok on localhost but same problem as dtterm when xterm on remote 
 host
 
 so I see two difficulties:
 1) get same behavior on remote host as localhost
 2) stop the old_xterm_title from printing to the command line in dtterm 
 (localhost)  xterm (remote)

In my humble opinion the restore does not work over network
because the implementation is fundamentally broken.

See:

printf (\e[21t);
fflush (stdout);

nodelay (stdscr, TRUE);
usleep(1000);
while (i  255  (c=getch()) != -1) {
title[i++] = c;
}
nodelay (stdscr, FALSE);

If the response of the terminal, which must travel over
network, is not available in mere 1 milisecond, then the code 
fails. getch() in nonblocking mode immediately returns -1.

I don't like this approach at all.

Please try the patch attached to this message and report whether
the remote host problem went away.

But please note that the patch is an experimental version and may
not compile on your platform at all.

Thank you.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

diff -purN mc-4.6.0-pre2/src/main.c mc-4.6.0-pre2.new/src/main.c
--- mc-4.6.0-pre2/src/main.cThu Dec 26 17:38:37 2002
+++ mc-4.6.0-pre2.new/src/main.cSun Jan  5 05:23:15 2003
@@ -2406,11 +2406,86 @@ compatibility_move_mc_files (void)
 }
 #endif /* NATIVE_WIN32 */
 
+static void 
+xterm_sig_alrm_h (int sig) {
+/* Do nothing.
+ * The only purpose of this signal is to interrupt the 
+ * read system call in xterm_read_title(). */
+}
+
+static char *
+store_xterm_title (void)
+{
+static char title[256];
+struct sigaction sa;
+int cnt;
+char *cmd = \033[21t;
+int e;
+int tty;
+
+if ((tty = open(/dev/tty, O_RDWR | O_NOCTTY)) == -1) {
+return (NULL);
+}
+/* Make sure we will not be blocked infinitely. */
+sa.sa_handler = xterm_sig_alrm_h;
+sa.sa_flags = SA_INTERRUPT | SA_RESETHAND;
+sigaction(SIGALRM, sa, NULL);
+alarm(5);
+
+/* Write the request for window title. */
+e = strlen(cmd); 
+while ((cnt = write(tty, cmd, e))  0) {
+e -= cnt;
+cmd += cnt;
+}
+
+if (cnt == -1) {
+close(tty);
+return (NULL);
+}
+else {
+/* Read the response. */
+int i = 0;
+char ch;
+int seen_esc = 0;
+while (i  sizeof(title)  read(tty, ch, 1)  0) {
+if (seen_esc == 0) {
+if (ch == '\033')
+seen_esc = 1;
+else
+continue;
+}
+if (ch == '\x9c')  /* ST */
+break;
+title[i++] = ch;
+}
+close(tty);
+if (i  4) {
+return (NULL);
+}
+else {
+title[i] = '\0';
+return (title + 3); /* OSC l */
+}
+}
+}
+
+
+static void
+restore_xterm_title (const unsigned char *title)
+{
+if (title != NULL) {
+   printf(\e]0;%s\a, title);
+   fflush(stdout);
+}
+}  
+
 int
 main (int argc, char *argv[])
 {
 /* if on, it displays the information that files have been moved to ~/.mc */
 int show_change_notice = 0;
+unsigned char *old_xterm_title = NULL;
 
 /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
 setlocale (LC_ALL, );
@@ -2513,9 +2588,17 @@ main (int argc, char *argv[])
 #endif /* HAVE_SUBSHELL_SUPPORT */
prompt = (geteuid () == 0) ? #  : $ ;
 
+/* Must be done after slang_init, init_curses, init_xterm_support */
+if (xterm_flag)
+old_xterm_title = store_xterm_title();
+
 /* Program main loop */
 do_nc ();
 
+if (xterm_flag  xterm_title  old_xterm_title)
+restore_xterm_title(old_xterm_title);
+   
+
 /* Save the tree store */
 tree_store_save ();
 



Re: a solution for high and dry xterm_title

2003-01-04 Thread Tomas Styblo
* Adam Byrtek 'alpha' [EMAIL PROTECTED] [Wed, 01 Jan 2003]:
 It was recently discussed on this list, and I've made a patch to store
 and restore old title:

I tested the title reporting ability of few popular terminal
emulators. All of them support title change, but these ones do not
support title reporting correctly or at all:

konsole
gnome-terminal
aterm

Personally I think that relying on the title reporting ability 
is too error prone.

 From the point of view of the user the easiest way to restore 
the title is to simply generate it in the PS1 variable as a part of
the command prompt. That way it's automatically updated when an 
application exits and also can contain name of the working
directory etc..

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [BUG] urar extfs in mc-4.6.0-pre2

2003-01-03 Thread Tomas Styblo
* Andrew V. Samoilov [EMAIL PROTECTED] [Fri, 03 Jan 2003]:
 Tomas Styblo wrote:
 ~~~ SNIP ~~~
 If a command is not found, the exit status shall be 127. If the
 command name is found, but it is not an executable utility, the
 exit status shall be 126.
 ~~~ SNIP ~~~
 
 Sorry, but it should be too easy to be true.  Zsh returns 1 in this 
 case.  And some distros symlinks zsh as /bin/sh.

I experimented with the unrar and found that

unrar l /dev/null /dev/null 21

returns zero. This tells unrar to list an empty archive.

Maybe we could use it ?

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [PATCH] lynx-like jumpkeys

2003-01-02 Thread Tomas Styblo
* Pavel Machek [EMAIL PROTECTED] [Wed, 25 Dec 2002]:
 Timeout breaks randomly on overloaded systems
 and slow networks. Bad idea. 

I agree that the slow network argument is good.

 What about non-number key ending move-by-number
 mode? No timeouts neccessary.

Good idea. I'll try to implement that.

 I still dont see how it is better than C-S, through.

Dead Can Dance - Spiritchaser [01] - Nierika.mp3
Dead Can Dance - Spiritchaser [02] - Song Of The Stars.mp3
Dead Can Dance - Spiritchaser [03] - Indus.mp3
Dead Can Dance - Spiritchaser [04] - Song Of The Dispossessed.mp3
Dead Can Dance - Spiritchaser [05] - Dedicace Outo.mp3
Dead Can Dance - Spiritchaser [06] - Snake And The Moon.mp3
Dead Can Dance - Spiritchaser [07] - Song Of The Nile.mp3
Dead Can Dance - Spiritchaser [08] - Devorzhum.mp3
Dead Can Dance - Within The Realm Of A Dying Sun [01] - Anywhere Out Of ~.mp3
Dead Can Dance - Within The Realm Of A Dying Sun [02] - Windfall.mp3
Dead Can Dance - Within The Realm Of A Dying Sun [03] - In The Wake Of Ad~.mp3
Dead Can Dance - Within The Realm Of A Dying Sun [04] - Xavier.mp3
Dead Can Dance - Within The Realm Of A Dying Sun [05] - Dawn Of The Icono~.mp3
Dead Can Dance - Within The Realm Of A Dying Sun [06] - Cantara.mp3
Dead Can Dance - Within The Realm Of A Dying Sun [07] - Summoning Of The ~.mp3
Dead Can Dance - Within The Realm Of A Dying Sun [08] - Persephone.mp3

no comment

Additionaly, CTRL+S does not work in listboxes. I personally like
this feature especially in the directory hotlist listbox. It's very
convenient to remember those numbers and switch to a directory
quickly just by typing CTRL + / + 15 + ENTER.

Of course it would be possible to split the patch into two pieces.
The first one implementing the jumpkeys in panels and the second one
implementing them in listboxes.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [BUG] urar extfs in mc-4.6.0-pre2

2003-01-02 Thread Tomas Styblo
* Andrew V. Samoilov [EMAIL PROTECTED] [Thu, 02 Jan 2003]:
 Unfortunatelly which is not portable.  I don't know is it documented in 
 unrar to return 7 if it was called without arguments, or this is some 
 random value dependent on compiler, architecture and temperature.

It definitely is not documented in the documentation that comes
with the package.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [BUG] urar extfs in mc-4.6.0-pre2

2003-01-02 Thread Tomas Styblo
* Pavel Roskin [EMAIL PROTECTED] [Thu, 02 Jan 2003]:
  Unfortunatelly which is not portable.  I don't know is it
  documented in unrar to return 7 if it was called without
  arguments, or this is some random value dependent on compiler,
  architecture and temperature.
 
 However, if unrar is missing, the error code is always the same
 (130 if I remember correctly) under every shell, so you can test
 it.

This is what SUSv3 says:

~~~ SNIP ~~~
If a command is not found, the exit status shall be 127. If the
command name is found, but it is not an executable utility, the
exit status shall be 126.
~~~ SNIP ~~~

Return value 130 would mean the process was killed by SIGINT.

 You can also find a simplified PATH search in shell in the
 bootstrap script in CVS automake.

It's less complicated to just test the return value.

New version of the bugfix is attached.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

diff -purN mc-4.6.0-pre2/vfs/extfs/urar.in mc-4.6.0-pre2.new/vfs/extfs/urar.in
--- mc-4.6.0-pre2/vfs/extfs/urar.in Thu Dec 12 15:08:25 2002
+++ mc-4.6.0-pre2.new/vfs/extfs/urar.in Thu Jan  2 23:45:15 2003
@@ -8,15 +8,24 @@
 #
 RAR=rar
 UNRAR=unrar # Prefer unrar (freeware)
+RET_CMD_NOT_EXEC=126
+RET_CMD_NOT_FOUND=127
 #
 # NOTE: rar ver 2.0 by Eugene Roshal
 # ftp.elf.stuba.sk/pub/pc/pack
 #
 
-if ! unrar /dev/null 21; then
+$UNRAR /dev/null 21
+if test $? -eq $RET_CMD_NOT_FOUND -o $? -eq $RET_CMD_NOT_EXEC; then
 UNRAR=$RAR
+$UNRAR /dev/null 21
+if test $? -eq $RET_CMD_NOT_FOUND -o $? -eq $RET_CMD_NOT_EXEC; then
+echo Cannot find rar or unrar in system PATH 2
+exit 1
+fi
 fi
 
+
 mcrarfs_list ()
 {
  $UNRAR v -c- $1 | @AWK@ -v uid=${UID-0} '



Re: [BUG] urar extfs in mc-4.6.0-pre2

2003-01-02 Thread Tomas Styblo
* Tomas Styblo [EMAIL PROTECTED] [Thu, 02 Jan 2003]:
 New version of the bugfix is attached.

I have to reply to my own post.

This is an update to the patch.

I looked up the test command in the standard and noticed that the
-o option is an XSI extension.

The lines

if test $? -eq $RET_CMD_NOT_FOUND -o $? -eq $RET_CMD_NOT_EXEC; then

were changed to

if test $? -eq $RET_CMD_NOT_FOUND || test $? -eq $RET_CMD_NOT_EXEC; then

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

diff -purN mc-4.6.0-pre2/vfs/extfs/urar.in mc-4.6.0-pre2.new/vfs/extfs/urar.in
--- mc-4.6.0-pre2/vfs/extfs/urar.in Thu Dec 12 15:08:25 2002
+++ mc-4.6.0-pre2.new/vfs/extfs/urar.in Fri Jan  3 06:58:54 2003
@@ -7,16 +7,25 @@
 # beta version 2.0
 #
 RAR=rar
-UNRAR=unrar # Prefer unrar (freeware)
+UNRAR=unrarx # Prefer unrar (freeware)
+RET_CMD_NOT_EXEC=126
+RET_CMD_NOT_FOUND=127
 #
 # NOTE: rar ver 2.0 by Eugene Roshal
 # ftp.elf.stuba.sk/pub/pc/pack
 #
 
-if ! unrar /dev/null 21; then
+$UNRAR /dev/null 21
+if test $? -eq $RET_CMD_NOT_FOUND || test $? -eq $RET_CMD_NOT_EXEC; then
 UNRAR=$RAR
+$UNRAR /dev/null 21
+if test $? -eq $RET_CMD_NOT_FOUND || test $? -eq $RET_CMD_NOT_EXEC; then
+echo Cannot find rar or unrar in system PATH 2
+exit 1
+fi
 fi
 
+
 mcrarfs_list ()
 {
  $UNRAR v -c- $1 | @AWK@ -v uid=${UID-0} '



[BUG] extfs - rpm archives

2002-12-29 Thread Tomas Styblo


Hello.

I finally installed pre2 and discovered that browsing of rpm
archives no longer works. This problem was not present in pre1.

A short error message is displayed:

Inconsistent extfs archive

My rpm version is 4.0.4.

This problem happens every time.

The problem is somewhere in the /usr/local/share/mc/extfs/rpm
file. When I replaced it with the same file from pre1,
the problem disappeared.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [PATCH] history_ignoredups (was: [PATCH] HISTCONTROL_ignoredups)

2002-12-29 Thread Tomas Styblo

Hello.

I updated the history ignore duplicates patch for pre2.

It has following effects:

- Duplicates in existing history file are discarded when the
  history is loaded.

- If a newly inserted entry is a duplicate of an existing entry,
  then the older entry is moved to the first position in the list
  (from the point of view of the user) and the new entry is not
  inserted again.

I also put the patch to the patch tracker.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

diff -purN mc-4.6.0-pre2/src/widget.c mc-4.6.0-pre2.new/src/widget.c
--- mc-4.6.0-pre2/src/widget.c  Thu Dec 26 00:31:14 2002
+++ mc-4.6.0-pre2.new/src/widget.c  Sun Dec 29 09:14:07 2002
@@ -803,12 +803,12 @@ int num_history_items_recorded = 60;
 Hist *
 history_get (char *input_name)
 {
-int i;
-Hist *old, *new;
+int i, omitdup = 0;
+Hist *old, *new, *hd;
 char *profile;
-
-old = new = NULL;
-
+
+old = new = hd = NULL;
+
 if (!num_history_items_recorded)   /* this is how to disable */
return 0;
 if (!input_name)
@@ -823,12 +823,25 @@ history_get (char *input_name)
GetPrivateProfileString (input_name, key_name, , this_entry, sizeof 
(this_entry), profile);
if (!*this_entry)
break;
-   new = g_new0 (Hist, 1);
-   new-text = g_strdup (this_entry);
-   new-prev = old;/* set up list pointers */
-   if (old)
-   old-next = new;
-   old = new;
+
+   /* Test if current entry is a duplicate. */
+   hd = old;
+   omitdup = 0;
+   while (hd) {
+   if (! strcmp (hd-text, this_entry)) {
+   omitdup = 1;
+   break;
+   }
+   hd = hd-prev;
+   }
+   if (! omitdup) {
+   new = g_new0 (Hist, 1);
+   new-text = g_strdup (this_entry);
+   new-prev = old;/* set up list pointers */
+   if (old)
+   old-next = new;
+   old = new;
+   }
 }
 g_free (profile);
 return new;/* return pointer to last entry in list */
@@ -837,9 +850,10 @@ history_get (char *input_name)
 void
 history_put (char *input_name, Hist *h)
 {
-int i;
+int i, omitdup = 0;
 char *profile;
-
+Hist *hd;
+
 if (!input_name)
return;
 
@@ -853,7 +867,6 @@ history_put (char *input_name, Hist *h)
return;
 
 profile = concat_dir_and_file (home_dir, HISTORY_FILE_NAME);
-
 if ((i = open (profile, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) != -1)
close (i);
 /* Just in case I forgot to strip passwords somewhere -- Norbert */
@@ -873,11 +886,21 @@ history_put (char *input_name, Hist *h)
profile_clean_section (input_name, profile);
 
 /* dump histories into profile */
-for (i = 0; h; h = h-next){
-   if (h-text){
+for (i = 0; h; h = h-next) {
+   if (h-text) {
+   /* Test if current entry is a duplicate. */
+   hd = h-prev;
+   omitdup = 0;
+   while (hd) {
+   if (! strcmp (hd-text, h-text)) {
+   omitdup = 1;
+   break;
+   }
+   hd = hd-prev;
+   }
 
-   /* probably aren't any null entries, but lets be sure */
-   if (*(h-text)){
+   /* Skip duplicates and make sure there aren't any null entries. */
+   if (! omitdup  *(h-text)){
char key_name[BUF_TINY];
g_snprintf (key_name, sizeof(key_name), %d, i++);
WritePrivateProfileString (input_name, key_name, h-text, profile);
@@ -1049,7 +1072,7 @@ push_history (WInput *in, char *text)
N_( FTP to machine ),
N_( SMB link to machine )
 };
-Hist *new;
+Hist *new, *hd;
 char *p;
 int i;
 
@@ -1063,11 +1086,32 @@ push_history (WInput *in, char *text)
 if (!*p)
 return 0;
 if (in-history){
+   /* Go to the last element of the history list. */
while (in-history-next)
in-history = in-history-next;
-   if (!strcmp (in-history-text, text))
-   return 1;
-   new = g_new (Hist, 1);
+   /* If the new entry is a duplicate of any of the existing 
+* entries then move it to the end of the history list
+* instead of pushing it again. The result is that the last
+* command used is always presented as the first choice. */
+   hd = in-history;
+   while (hd) {
+   if (! strcmp(hd-text, text)) {
+   if (hd != in-history) {
+   /* If the found dup is not the last entry
+* then move the dup to the end. */
+   in-history-next = hd;
+   hd-next-prev = hd-prev;
+   if (hd-prev) /* If dup is not first entry. */
+   hd-prev-next = hd-next;
+   hd-next = NULL;
+   hd-prev = in-history

Re: [BUG] urar extfs in mc-4.6.0-pre2

2002-12-29 Thread Tomas Styblo
* Dmitry Semyonov [EMAIL PROTECTED] [Sun, 29 Dec 2002]:
 I'm unable to enter *.rar archives.
 
 I have 'UNRAR 2.71 freeware  Copyright (c) 1993-2000 Eugene Roshal'
 installed in /usr/bin.

Support for rar archives in pre2 works for me with rar/unrar:

RAR 3.00 beta 6Copyright (c) 1993-2002 Eugene Roshal19 Apr 2002

You can get it at:

http://www.rarlab.com/rar/rarlinux-3.1.0.tar.gz


-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [BUG] urar extfs in mc-4.6.0-pre2

2002-12-29 Thread Tomas Styblo
* Dmitry Semyonov [EMAIL PROTECTED] [Mon, 30 Dec 2002]:
 I have only unrar installed. This shall be enough to brouse rar
 archives and to extract files from them.  I'll try to upgrade to
 unrar 3.x (after Jan,9), and see how it works.  But even if it
 will work, do you think it is OK to use such unrar detection
 code that can't properly detect old versions of unrar inside
 urar extfs script?

The problem is not that mc can't find the unrar executable.

There is a bug in the new urar script.

The pre1 version of the script goes like:

DRAR=/usr/bin
RAR=$DRAR/rar
UNRAR=$DRAR/unrar # Prefer unrar (freeware)


The pre2 version goes like:

RAR=rar
UNRAR=unrar # Prefer unrar (freeware)
if ! unrar /dev/null 21; then
UNRAR=$RAR
fi


Therefore it fails if the rar executable is not present in the
system, because the if ! unrar test always fails. It always
fails, because unrar exits with code 7 if it is called with no
arguments.

Both the rar and unrar executables are installed by default if you
use the above mentioned version 3 of the rar package. It's
probably the easiest solution for you now. But the urar script of
course should be fixed.

The bugfix patch is attached to this message.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

diff -purN mc-4.6.0-pre2/vfs/extfs/urar.in mc-4.6.0-pre2.new/vfs/extfs/urar.in
--- mc-4.6.0-pre2/vfs/extfs/urar.in Thu Dec 12 15:08:25 2002
+++ mc-4.6.0-pre2.new/vfs/extfs/urar.in Mon Dec 30 00:57:01 2002
@@ -6,17 +6,22 @@
 #Andrew V. Samoilov [EMAIL PROTECTED] 2000
 # beta version 2.0
 #
-RAR=rar
-UNRAR=unrar # Prefer unrar (freeware)
+RAR=`which rar 2/dev/null`
+UNRAR=`which unrar 2/dev/null` # Prefer unrar (freeware)
 #
 # NOTE: rar ver 2.0 by Eugene Roshal
 # ftp.elf.stuba.sk/pub/pc/pack
 #
 
-if ! unrar /dev/null 21; then
+if test -z $UNRAR; then
 UNRAR=$RAR
 fi
 
+if test -z $UNRAR; then
+echo Cannot find unrar or rar executable in PATH 2 
+exit 1
+fi
+
 mcrarfs_list ()
 {
  $UNRAR v -c- $1 | @AWK@ -v uid=${UID-0} '



Re: [PATCH] lynx-like jumpkeys

2002-12-29 Thread Tomas Styblo
* Adam Byrtek 'alpha' [EMAIL PROTECTED] [Sun, 22 Dec 2002]:
 Maybe after the release you could port this to cvs version?

I updated the patch for 4.6.0-pre2. It was also submitted to
the patch tracker.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

diff -purN mc-4.6.0-pre2/doc/mc.1.in mc-4.6.0-pre2.dev/doc/mc.1.in
--- mc-4.6.0-pre2/doc/mc.1.in   Thu Dec 26 21:15:51 2002
+++ mc-4.6.0-pre2.dev/doc/mc.1.in   Mon Dec 30 04:39:42 2002
@@ -344,6 +344,13 @@ return to your application just type C-o
 suspended by using this trick, you won't be able to execute other
 programs from the Midnight Commander until you terminate the suspended
 application.
+.TP
+.B number keys,
+When the lynx-like jumpkeys configuration option is enabled, then you
+can use number keys to select numbered entries in the panels, the
+history and the hotlist. More information about this feature is in
+the Configuration: Panel Options section.
+.PP
 .\NODE   Directory Panels
 .SH   Directory Panels
 This section lists the keys which operate on the directory panels. If
@@ -591,6 +598,12 @@ does the filename, command, variable, us
 completion
 .\Completion
 for you.
+.PP
+When the configuration option lynx-like jumpkeys is enabled and the
+command line is empty, then the number keys are intercepted by the
+panels. To execute a command which begins with a number, the command
+must be prefixed with a space.
+.PP
 .SH 
 .\NODE Menu Bar
 .SH Menu Bar
@@ -740,6 +753,9 @@ the group of the file.
 .TP
 .B inode
 the inode of the file.
+.TP
+.B jumpkey,
+number of the entry, used by the lynx-like jumpkeys feature.
 .PP
 Also you can use following keywords to define the panel layout:
 .TP
@@ -1568,6 +1584,14 @@ mode or owner changes, etc) the display 
 if you have the option on, you have to rescan the directory manually
 (with C-r).
 .PP
+.I Lynx-like jumpkeys.
+This option enables a lynx-like navigation using numbered entries in
+the panels and other widgets. Each displayed entry is numbered and
+may be selected by one or two keystrokes.
+To select for example a file or a hotlist entry numbered 23, 
+just press the keys 2 and 3 in quick succession.
+The selection cursor will immediately move to that entry.
+.PP
 .B Pause after run
 .PP
 After executing your commands, the Midnight Commander can pause, so
diff -purN mc-4.6.0-pre2/src/complete.c mc-4.6.0-pre2.dev/src/complete.c
--- mc-4.6.0-pre2/src/complete.cWed Nov 13 07:06:34 2002
+++ mc-4.6.0-pre2.dev/src/complete.cMon Dec 30 04:33:45 2002
@@ -995,6 +995,7 @@ complete_engine (WInput *in, int what_to
dialog_colors, query_callback,
[Completion], NULL, DLG_COMPACT);
query_list = listbox_new (1, 1, w - 2, h - 2, 0, querylist_callback, NULL);
+query_list-use_jumpkeys = 0; /* never use jumpkeys in completion menu */
add_widget (query_dlg, query_list);
for (p = in-completions + 1; *p; p++)
listbox_add_item (query_list, 0, 0, *p, NULL);
diff -purN mc-4.6.0-pre2/src/dir.h mc-4.6.0-pre2.dev/src/dir.h
--- mc-4.6.0-pre2/src/dir.h Fri Nov 15 07:44:16 2002
+++ mc-4.6.0-pre2.dev/src/dir.h Mon Dec 30 04:33:45 2002
@@ -10,6 +10,7 @@ typedef struct {
 /* File attributes */
 
 int  fnamelen;
+int  jumpkey_num;
 char *fname;
 struct stat  buf;
 
diff -purN mc-4.6.0-pre2/src/main.c mc-4.6.0-pre2.dev/src/main.c
--- mc-4.6.0-pre2/src/main.cThu Dec 26 17:38:37 2002
+++ mc-4.6.0-pre2.dev/src/main.cMon Dec 30 04:33:45 2002
@@ -282,6 +282,10 @@ static int edit_one_file_start_line = 0;
shut down */
 int midnight_shutdown = 0;
 
+/* Grab number keys in panels and listbox widgets and use them
+ * as lynx-like jumpkeys */
+int use_jumpkeys = 0;
+
 /* to show nice prompts */
 static int last_paused = 0;
 
@@ -1181,6 +1185,20 @@ toggle_show_hidden (void)
 update_panels (UP_RELOAD, UP_KEEPSEL);
 }
 
+void
+toggle_use_jumpkeys (void)
+{
+int i;
+WPanel *p;
+
+use_jumpkeys = !use_jumpkeys;
+for (i = 0; i = 1; i++) {
+p = (i == 0 ? left_panel : right_panel);
+if (p) set_panel_formats (p);
+}
+update_panels (UP_RELOAD, UP_KEEPSEL);
+}
+
 /*
  * Just a hack for allowing url-like pathnames to be accepted from the
  * command line.
diff -purN mc-4.6.0-pre2/src/main.h mc-4.6.0-pre2.dev/src/main.h
--- mc-4.6.0-pre2/src/main.hThu Dec 26 17:20:51 2002
+++ mc-4.6.0-pre2.dev/src/main.hMon Dec 30 04:33:45 2002
@@ -5,6 +5,7 @@ void toggle_fast_reload (void);
 void toggle_mix_all_files (void);
 void toggle_show_backup (void);
 void toggle_show_hidden (void);
+void toggle_use_jumpkeys (void);
 
 enum {
 RP_NOCLEAR,
@@ -80,6 +81,7 @@ extern int alternate_plus_minus;
 extern int only_leading_plus_minus;
 extern int output_starts_shell;
 extern int midnight_shutdown;
+extern int use_jumpkeys;
 extern char search_buffer [256];
 extern char cmd_buf

Re: [PATCH] lynx-like jumpkeys

2002-12-22 Thread Tomas Styblo
* Adam Byrtek 'alpha' [EMAIL PROTECTED] [Sun, 22 Dec 2002]:
 By the way jumpkeys in panel are not too useful, I think it is
 easier to type part of a real filename than a random number. But I
 guess it depends on habits.

You can disable the jumpkeys in panel and still have them in the
listboxes. You can use the Listing mode configuration menu to
specify your own user defined format. The default Full file list
format without the jumpkeys is:

half type,name,|,size,|,mtime

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [PATCH] HISTCONTROL_ignoredups (was: [PATCH] history_show_duplicates)

2002-12-18 Thread Tomas Styblo
* Pavel Roskin [EMAIL PROTECTED] [Mon, 09 Dec 2002]:
   Here is the new patch. It allows the user to set the
   HISTCONTROL environment variable to a value of ignoredups
   if he wants to have only unique entries in history widgets.
  
  Maybe duplicates should be always ignored?
 
 Maybe.  The only widget where the duplicates make sense is the
 command line (the history is shown by Alt-h on the panels).

[...]

 If anybody will seriously miss full history with duplicates in
 any widget, please explain the reason.

So what's the final decision ? Should I prepare a new version of
the patch in which the duplicates will always be ignored ?

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [PATCH] xterm titlebar

2002-12-17 Thread Tomas Styblo
* Adam Byrtek 'alpha' [EMAIL PROTECTED] [Tue, 17 Dec 2002]:
  mc running in the linux console and it does nothing at all. Which
  I suppose is good. :) But maybe a check for getenv(DISPLAY)
 
 Se source:
 
 if (xterm_flag  !xterm_hintbar) {
 
 xterm_flag takes care of this.

You are right, I was wrong and did not notice that.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [PATCH] lynx-like jumpkeys

2002-12-17 Thread Tomas Styblo

Here is an updated version of the patch.

In previous version the jumpkey numbers were displayed even for
empty entries. This was most noticeable in the hotlist. I think it
was quite confusing. Now the numbers are displayed only for
non-empty entries.

The new version of the patch is attached to this message.

The only difference between the two versions:

diff -purN mc-4.6.0-pre1/src/widget.c mc-4.6.0-pre1.new/src/widget.c
--- mc-4.6.0-pre1/src/widget.c  Wed Dec 18 04:04:33 2002
+++ mc-4.6.0-pre1.new/src/widget.c  Wed Dec 18 04:04:17 2002
@@ -1729,7 +1729,7 @@ listbox_draw (WListbox *l, Dlg_head *h, 
text = e-text;
e = e-next;
}
-   if (l-use_jumpkeys)
+   if (l-use_jumpkeys  *text)
printw ( %3d | %-*s , i + 1, l-width-7, name_trunc (text, l-width-7));
else
printw ( %-*s , l-width-2, name_trunc (text, l-width-2));


-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

diff -purN mc-4.6.0-pre1/doc/mc.1.in mc-4.6.0-pre1.new/doc/mc.1.in
--- mc-4.6.0-pre1/doc/mc.1.in   Wed Aug 21 03:08:46 2002
+++ mc-4.6.0-pre1.new/doc/mc.1.in   Wed Dec 18 03:23:49 2002
@@ -337,6 +337,12 @@ suspended by using this trick, you won't
 programs from the Midnight Commander until you terminate the suspended
 application.
 .PP
+.B number keys,
+When the lynx-like jumpkeys configuration option is enabled, then you
+can use number keys to select numbered entries in the panels, the
+history and the hotlist. More information about this feature is in
+the Configuration: Panel Options section.
+.PP
 .SH   Directory Panels
 This section lists the keys which operate on the directory panels. If
 you want to know how to change the appearance of the panels take a
@@ -585,6 +591,11 @@ completion
 .\Completion
 for you.
 .PP
+When the configuration option lynx-like jumpkeys is enabled and the
+command line is empty, then the number keys are intercepted by the
+panels. To execute a command which begins with a number, the command
+must be prefixed with a space.
+.PP
 .SH 
 .SH Menu Bar
 The menu bar pops up when you press F9 or click the mouse on the top
@@ -732,6 +743,9 @@ the group of the file.
 .B inode,
 the inode of the file.
 .PP
+.B jumpkey,
+number of the entry, used by the lynx-like jumpkeys feature.
+.PP
 Also you may use these field names for arranging the display:
 .PP
 .B space,
@@ -1569,6 +1583,14 @@ mode or owner changes, etc) the display 
 if you have the option on, you have to rescan the directory manually
 (with C-r).
 .PP
+.I Lynx-like jumpkeys.
+This option enables a lynx-like navigation using numbered entries in
+the panels and other widgets. Each displayed entry is numbered and
+may be selected by one or two keystrokes.
+To select for example a file or a hotlist entry numbered 23, 
+just press the keys 2 and 3 in quick succession.
+The selection cursor will immediately move to that entry.
+.PP
 .B Pause after run
 .PP
 After executing your commands, the Midnight Commander can pause, so
diff -purN mc-4.6.0-pre1/src/complete.c mc-4.6.0-pre1.new/src/complete.c
--- mc-4.6.0-pre1/src/complete.cTue Mar 26 03:09:39 2002
+++ mc-4.6.0-pre1.new/src/complete.cWed Dec 18 03:23:49 2002
@@ -990,6 +990,7 @@ complete_engine (WInput *in, int what_to
dialog_colors, query_callback,
[Completion], complete, DLG_NONE);
query_list = listbox_new (1, 1, w - 2, h - 2, 0, querylist_callback, NULL);
+query_list-use_jumpkeys = 0; /* never use jumpkeys in completion menu */
add_widget (query_dlg, query_list);
for (p = in-completions + 1; *p; p++)
listbox_add_item (query_list, 0, 0, *p, NULL);
diff -purN mc-4.6.0-pre1/src/dir.h mc-4.6.0-pre1.new/src/dir.h
--- mc-4.6.0-pre1/src/dir.h Fri Dec 28 02:11:52 2001
+++ mc-4.6.0-pre1.new/src/dir.h Wed Dec 18 03:23:49 2002
@@ -10,6 +10,7 @@ typedef struct {
 /* File attributes */
 
 int  fnamelen;
+int  jumpkey_num;
 char *fname;
 struct stat  buf;
 
diff -purN mc-4.6.0-pre1/src/main.c mc-4.6.0-pre1.new/src/main.c
--- mc-4.6.0-pre1/src/main.cWed Aug 21 03:08:49 2002
+++ mc-4.6.0-pre1.new/src/main.cWed Dec 18 03:23:49 2002
@@ -286,6 +286,10 @@ static int edit_one_file_start_line = 1;
shut down */
 int midnight_shutdown = 0;
 
+/* Grab number keys in panels and listbox widgets and use them
+ * as lynx-like jumpkeys */
+int use_jumpkeys = 0;
+
 /* to show nice prompts */
 static int last_paused = 0;
 
@@ -1176,6 +1180,20 @@ toggle_show_hidden (void)
 update_panels (UP_RELOAD, UP_KEEPSEL);
 }
 
+void
+toggle_use_jumpkeys (void)
+{
+int i;
+WPanel *p;
+
+use_jumpkeys = !use_jumpkeys;
+for (i = 0; i = 1; i++) {
+p = (i == 0 ? left_panel : right_panel);
+if (p) set_panel_formats (p);
+}
+update_panels (UP_RELOAD, UP_KEEPSEL);
+}
+
 /*
  * Just a hack for allowing

[BUGFIX] hotlist group label

2002-12-17 Thread Tomas Styblo

Hi.

There is a bug in the hotlist menu. The group label is not updated
if you open an empty group. This happens everytime when you
create a new group and open it.

To reproduce it:

- open the hotlist (ctrl+'\')
- create New Group
- open it
- the label does not change

The included patch fixes it. It ensures that the label is updated
everytime a group is selected, even if it is empty.


-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

diff -purN mc-4.6.0-pre1/src/hotlist.c mc-4.6.0-pre1.new/src/hotlist.c
--- mc-4.6.0-pre1/src/hotlist.c Tue Aug 20 04:57:25 2002
+++ mc-4.6.0-pre1.new/src/hotlist.c Wed Dec 18 03:46:20 2002
@@ -171,13 +171,6 @@ static inline void update_path_name (voi
text = hlp-directory;
else
text = _(Subgroup - press ENTER to see list);
-   
-   p = g_strconcat ( , current_group-label,  , NULL);
-   if (!hotlist_state.moving)
-   label_set_text (pname_group, name_trunc (p, dlg-cols - (UX*2+4)));
-   else
-   label_set_text (movelist_group, name_trunc (p, dlg-cols - (UX*2+4)));
-   g_free (p);
} else {
text = list-current-text;
}
@@ -186,6 +179,14 @@ static inline void update_path_name (voi
 }
 if (!hotlist_state.moving)
label_set_text (pname, name_trunc (text, dlg-cols - (UX*2+4)));
+
+p = g_strconcat ( , current_group-label,  , NULL);
+if (!hotlist_state.moving)
+   label_set_text (pname_group, name_trunc (p, dlg-cols - (UX*2+4)));
+else
+   label_set_text (movelist_group, name_trunc (p, dlg-cols - (UX*2+4)));
+g_free (p);
+
 dlg_redraw (dlg);
 }
 



Re: [PATCH] xterm titlebar

2002-12-16 Thread Tomas Styblo
* Adam Byrtek 'alpha' [EMAIL PROTECTED] [Mon, 16 Dec 2002]:
 On Mon, Dec 16, 2002 at 03:52:56AM +0100, Tomas Styblo wrote:
  1) The malloced space was never freed. Fixed by replacing
 it with an automatic array.
 
 Allocation is not necessary. cpanel-cwd gives us working dir.

Yeah, it's actually amusing how often the simplest solution is
the most correct one :)

Regarding the comments in the bug tracker, I also think that the
patch is already very useful. Configurability would be nice, but
it's not necessary, IMHO.

The only problem I see is that when you switch to the background
shell using CTRL+o, cd to some other directory, then the title
is not updated. I don't how difficult would be to correct it ...

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



[PATCH] lynx-like jumpkeys

2002-12-16 Thread Tomas Styblo

Hello.

Here is a patch which adds a fast lynx-like navigation to the
panels and to the listbox widgets (history, hotlist, ...). Each
displayed entry is numbered and may be selected by one or two
keystrokes.

To select for example a file or a hotlist entry numbered 23,
just press the keys 2 and 3 in quick succession.  The
selection cursor will immediately move to that entry.

This type of keyboard navigation is used in lynx, mutt, slrn,
cscope, vim, links and many other programs. Once one gets used to
it, then it can help to save a lot of keystrokes.

For lack of a better term, I call this type of navigation
jumpkeys and use the term in descriptions and documentation.

There are two small pictures attached to this message which show
the feature in action.

When it is enabled, then the widgets intercept numeric keys. This
works without problem in listbox widgets, but requires a little
change of the command line input. The jumpkeys are processed only
when the command line is empty. This allows you to use numbers in
commands. Commands that start with a number may be executed by
prefixing them with a space ( 4command).

An option to enable this feature was added to the Configuration
menu. By default it's disabled.

The patch is against 4.6.0.pre1 and was tested on Linux.

It includes a documentation update.

Please bear in mind that I am a newbie regarding mc code.

It definitely needs a review.

Thanks.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6

attachment: mc3.pngattachment: mc6.pngdiff -purN mc-4.6.0-pre1/doc/mc.1.in mc-4.6.0-pre1.new/doc/mc.1.in
--- mc-4.6.0-pre1/doc/mc.1.in   Wed Aug 21 03:08:46 2002
+++ mc-4.6.0-pre1.new/doc/mc.1.in   Mon Dec 16 19:05:41 2002
@@ -337,6 +337,12 @@ suspended by using this trick, you won't
 programs from the Midnight Commander until you terminate the suspended
 application.
 .PP
+.B number keys,
+When the lynx-like jumpkeys configuration option is enabled, then you
+can use number keys to select numbered entries in the panels, the
+history and the hotlist. More information about this feature is in
+the Configuration: Panel Options section.
+.PP
 .SH   Directory Panels
 This section lists the keys which operate on the directory panels. If
 you want to know how to change the appearance of the panels take a
@@ -585,6 +591,11 @@ completion
 .\Completion
 for you.
 .PP
+When the configuration option lynx-like jumpkeys is enabled and the
+command line is empty, then the number keys are intercepted by the
+panels. To execute a command which begins with a number, the command
+must be prefixed with a space.
+.PP
 .SH 
 .SH Menu Bar
 The menu bar pops up when you press F9 or click the mouse on the top
@@ -732,6 +743,9 @@ the group of the file.
 .B inode,
 the inode of the file.
 .PP
+.B jumpkey,
+number of the entry, used by the lynx-like jumpkeys feature.
+.PP
 Also you may use these field names for arranging the display:
 .PP
 .B space,
@@ -1569,6 +1583,14 @@ mode or owner changes, etc) the display 
 if you have the option on, you have to rescan the directory manually
 (with C-r).
 .PP
+.I Lynx-like jumpkeys.
+This option enables a lynx-like navigation using numbered entries in
+the panels and other widgets. Each displayed entry is numbered and
+may be selected by one or two keystrokes.
+To select for example a file or a hotlist entry numbered 23, 
+just press the keys 2 and 3 in quick succession.
+The selection cursor will immediately move to that entry.
+.PP
 .B Pause after run
 .PP
 After executing your commands, the Midnight Commander can pause, so
diff -purN mc-4.6.0-pre1/src/complete.c mc-4.6.0-pre1.new/src/complete.c
--- mc-4.6.0-pre1/src/complete.cTue Mar 26 03:09:39 2002
+++ mc-4.6.0-pre1.new/src/complete.cMon Dec 16 19:52:56 2002
@@ -990,6 +990,7 @@ complete_engine (WInput *in, int what_to
dialog_colors, query_callback,
[Completion], complete, DLG_NONE);
query_list = listbox_new (1, 1, w - 2, h - 2, 0, querylist_callback, NULL);
+query_list-use_jumpkeys = 0; /* never use jumpkeys in completion menu */
add_widget (query_dlg, query_list);
for (p = in-completions + 1; *p; p++)
listbox_add_item (query_list, 0, 0, *p, NULL);
diff -purN mc-4.6.0-pre1/src/dir.h mc-4.6.0-pre1.new/src/dir.h
--- mc-4.6.0-pre1/src/dir.h Fri Dec 28 02:11:52 2001
+++ mc-4.6.0-pre1.new/src/dir.h Mon Dec 16 19:52:56 2002
@@ -10,6 +10,7 @@ typedef struct {
 /* File attributes */
 
 int  fnamelen;
+int  jumpkey_num;
 char *fname;
 struct stat  buf;
 
diff -purN mc-4.6.0-pre1/src/main.c mc-4.6.0-pre1.new/src/main.c
--- mc-4.6.0-pre1/src/main.cWed Aug 21 03:08:49 2002
+++ mc-4.6.0-pre1.new/src/main.cMon Dec 16 19:52:56 2002
@@ -286,6 +286,10 @@ static int edit_one_file_start_line = 1;
shut down */
 int midnight_shutdown = 0;
 
+/* Grab number keys in panels

Re: [PATCH] xterm titlebar

2002-12-15 Thread Tomas Styblo
* Adam Byrtek 'alpha' [EMAIL PROTECTED] [Thu, 12 Dec 2002]:

Hi !

 A patch to display mc's current working dir in xterm titlebar. I made
 it mostly for my own personal use - I often have many instances of mc
 on my desktop (sometimes shaded, sometimes minimized) and meaningful
 title helps me recognize one that I look for.

Thank you for this patch. My rxvt loves it ! :)

I enhanced it a bit:

1) The malloced space was never freed. Fixed by replacing
   it with an automatic array.

2) Home directory portion of the path is converted
   to '~'. It saves space which is valuable in taskbar
   buttons.

3) FTP passwords are now stripped from the path.

The modified version is attached to this message.

Bye.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
People demand freedom of speech as a compensation for
 the freedom of thought which they seldom use. -Kierkegaard

diff -purN mc-4.6.0-pre1/src/main.c mc-4.6.0-pre1.new/src/main.c
--- mc-4.6.0-pre1/src/main.cWed Aug 21 03:08:49 2002
+++ mc-4.6.0-pre1.new/src/main.cMon Dec 16 03:47:17 2002
@@ -1665,6 +1665,14 @@ make_panels_dirty (void)
 
 if ((get_other_type () == view_listing)  opanel-dirty)
panel_update_contents (opanel);
+
+/* refresh cwd in xterm titlebar */
+if (xterm_flag  !xterm_hintbar) {
+char cur_dir[MC_MAXPATHLEN + 1];
+mc_get_current_wd (cur_dir, MC_MAXPATHLEN);
+fprintf (stdout, \33]0;mc: %s\7, strip_home_and_password(cur_dir));
+fflush (stdout);
+}
 }
 
 /* In OS/2 and Windows NT people want to actually type the '\' key frequently */



Re: [PATCH] history_show_duplicates

2002-11-25 Thread Tomas Styblo
* Andrew V. Samoilov [EMAIL PROTECTED] [Mon, 25 Nov 2002]:
 Here is a patch which adds a new configuration option:
 
 history_show_duplicates
 
 The option specifies whether the history panels will show
 duplicate entries more than once. 
 
 Maybe it will be more consistent to use HISTCONTROL environment variable?

It's in fact a very good idea. I'll provide the new patch in a few
days.

-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
People demand freedom of speech as a compensation for
 the freedom of thought which they seldom use. -Kierkegaard



msg01349/pgp0.pgp
Description: PGP signature


[PATCH] history_show_duplicates

2002-11-24 Thread Tomas Styblo

Hi.

Here is a patch which adds a new configuration option:

history_show_duplicates

The option specifies whether the history panels will show
duplicate entries more than once. 

The default is to show the duplicates (which is how mc works now).

It's not possible to set the option in the configuration menu.

The patch includes update of the manpage. This update also
adds missing information on the num_history_items_recorded
option.

These files were modified:

src/setup.c
src/widget.c
doc/mc.1.in


-- 
Tomas Styblo [EMAIL PROTECTED]
PGP: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xC97EA4B6
People demand freedom of speech as a compensation for
 the freedom of thought which they seldom use. -Kierkegaard

diff -purN mc-4.6.0-pre1/doc/mc.1.in mc-4.6.0-pre1.new/doc/mc.1.in
--- mc-4.6.0-pre1/doc/mc.1.in   Wed Aug 21 03:08:46 2002
+++ mc-4.6.0-pre1.new/doc/mc.1.in   Sun Nov 24 08:24:03 2002
@@ -2990,6 +2990,15 @@ passive open mode for transferring files
 are behind a filtering packet router.  This option just works if you
 are not using an ftp proxy.
 .PP
+.I num_history_items_recorded
+.IP
+This value specifies maximum number of items recorded in history.
+.PP
+.I history_show_duplicates
+.IP
+This option is on by default. It specifies whether the history panels
+will show duplicate entries more than once.
+.PP
 .I max_dirt_limit.
 .IP
 Specifies how many screen updates can be skipped at most in the internal
diff -purN mc-4.6.0-pre1/src/setup.c mc-4.6.0-pre1.new/src/setup.c
--- mc-4.6.0-pre1/src/setup.c   Mon Aug 19 06:16:47 2002
+++ mc-4.6.0-pre1.new/src/setup.c   Sun Nov 24 08:23:34 2002
@@ -60,6 +60,7 @@
 extern char *find_ignore_dirs;
 
 extern int num_history_items_recorded;
+extern int history_show_duplicates;
 
 char *profile_name;/* .mc/ini */
 char *global_profile_name; /* mc.lib */
@@ -192,6 +193,7 @@ static const struct {
 { panel_scroll_pages, panel_scroll_pages },
 { xtree_mode, xtree_mode },
 { num_history_items_recorded, num_history_items_recorded },
+{ history_show_duplicates, history_show_duplicates },
 { file_op_compute_totals, file_op_compute_totals },
 #ifdef SAVE_CHANGES_OUTSIDE_OPTIONS_MENU
 { dive_into_subdirs, dive_into_subdirs },
diff -purN mc-4.6.0-pre1/src/widget.c mc-4.6.0-pre1.new/src/widget.c
--- mc-4.6.0-pre1/src/widget.c  Sat Jul 20 04:54:52 2002
+++ mc-4.6.0-pre1.new/src/widget.c  Sun Nov 24 08:22:57 2002
@@ -795,6 +795,7 @@ winput_set_origin (WInput *in, int x, in
  */
 
 int num_history_items_recorded = 60;
+int history_show_duplicates = 1;
 
 Hist *history_get (char *input_name)
 {
@@ -963,6 +964,7 @@ char *show_hist (Hist *history, int widg
 query_dlg = create_dlg (y, x, h, w, dialog_colors, history_callback,
[History-query], history, DLG_NONE);
 query_list = listbox_new (1, 1, w - 2, h - 2, listbox_finish, 0, NULL);
+query_list-allow_duplicates = history_show_duplicates;
 add_widget (query_dlg, query_list);
 hi = z;
 if (y  widget_y) {



msg01346/pgp0.pgp
Description: PGP signature