session management



moin,

first off, i think the file viewer should save the position (along with
other options, like hex, raw, etc.) per file, just like the editor does.
anyway, now for the real topic ...

in a "heavily x-windowed environment" you want session management. for
mc, that consists mostly of:
- the locations of both panels, including the the cursor position (yes,
  i demand a lot :) (1)
- an open viewer/editor, including state (position, options) specific to
  that particular instance (2)
- that unsaved changes in an editor are not lost. i.e., a nice
  yes/no/cancel dialog at shutdown time (3)

mc is an x client, so theoretically xsmp can be used to do real session
management.

in fact, (3) can be done perfectly, i think; even raising the correct
window for the dialog can be done, as all sane terminal emulators export
WINDOWID. getting notified about a shutdown and the ability to interrupt
it are part of xsmp.

saving and restoring the status to implement (1) & (2) is quite simple
as well, it just requires some work. :)

but there must be a problem, of course ;) ... as mc is no "native" x
client, but runs nested into a terminal emulator, communicating the
correct restart command to the session manager is a problem. what we
really want is a command line like "xterm -geometry ... -e mc --session
foo". i seriously doubt that xsmp provides any means to do "command line
merging", so mc could extend xterm's restart command. however, i think
the following would work: create a wrapper script xmc:

-----------
#! /bin/bash
# usage: xmc [--mc-option] ... terminal-emulator [options ...]

# this is a trivial version; it only works with --parm=arg options
# (i.e., single-element options). a full version needs to know each
# option's argument requirement.
while $# != 0; do
  case $1 in
    --*) opts=("$opts[ ]" "$1"); shift;;
    *) break;;
  esac
done

# uuidgen is currently part of libuuid1 on debian
exec "$@" -e mc --session ~/.mc/sessions/$(uuidgen) "$opts[ ]"
-----------

that way xterm (or whatever) sees a command line that already contains
the identifier of a session, which mc can use for its purposes. as xterm
saves the complete client command line across sessions, things just work
...

any takers?

greetings

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]