--
Ticket URL: <http://www.midnight-commander.org/ticket/2968>
Midnight Commander <http://www.midnight-commander.org>
Midnight Development Center
Comment (by szaszg):
The problem is:
- first mcviewer open the file with '''external helper''' (with: '''nroff
-c -Tlatin1 -mandoc''')
- this convert manpage to nroff formatted file with dblstike and underline
and so on...
- so mcview_display_nroff() can highlite the text
- after ctrl-f mcviewer open files without external helpers (only '''magic
mode''' works)
- mcview_display_nroff() see only the ''raw'' file (maximum uncompressed),
- so cannot highlite...
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:1>
Comment (by szaszg):
I attached a patch:
ext.{h,c}:
- regex_command renamed to regex_command_cb() and has a new argument
(callback) wich called, when not NULL and 'external helper command'
constructed (instead of exec_extension_view()).
- regex_command() call regex_command_cb() with NULL callback
- exec_extension() has a new argument (callback)
actions_cmd.c:
- new function: mcview_regex_cmd_cb() - callback for regex_command()
to save "cmd" and others
- mcview_load_next_prev() now uses regex_command_cb() to load
next/prev file with "external helper" if any
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:2>
Comment (by andrew_b):
You introduced several variables:
{{{
+static vfs_path_t *temp_file_name_vpath = NULL;
+static char *cmd = NULL;
+static int written_nonspace = 0;
}}}
These variables are shared between all viewers opened at the same time. Is
everything OK in this case?
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:3>
Comment (by szaszg):
Replying to [comment:3 andrew_b]:
> These variables are shared between all viewers opened at the same time.
Is everything OK in this case?
This variables exist to store the data needed for open the file with
external helper. mcview_regex_cmd_cb() fill this variables, when
regex_command_cb() call it. After mcview_load() we free them. So these
variables just for temp storage of the command filename and vpath...
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:4>
Comment (by andrew_b):
Unfortunately, your patch doesn't resolve the problem.
For example, go to the directory with man pages:
{{{
mc/BUILD_ROOT/INSTALL_ROOT/share/man/man1:
mc.1
mcedit.1
mcview.1
}}}
Press F3 on mc.1. You see parsed man page.
Press C-f. You see parsed man page mcedit.1.
Press F8 to switch to the raw mode. You see the raw mcedit.1. It's OK.
Press F8 to switch back to the parsed mode. You can see the warning like
following:
{{{/bin/sh: /tmp/.private/andrew/mc-andrew/mcext1FQQTW: No such file or
directory}}}.
Press Enter. The error {{{Empty output from child filter}}} is raised.
Press Enter. You see the clean viewer area instead of parsed mcedit.1.
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:5>
Comment (by szaszg):
Now, i replace the diff with a new one. I hope this fix all the problem in
this ticket and in ticket#2090.
1. filemanager/ext.{c,h}
- new struct: ext_command_cache_t
- new array: ext_command_cache_t
ext_command_cache[EXT_COMMAND_CACHE_SIZE]; to cache filter commands'
properties
- new variable: int command_cache_idx; to manage cache
- changed function: exec_extension_view() does not mc_unlink() filter
script anymore
- new function: flush_command_cache_member() to remove one cached
filter command
- new function: check_command_cache() lookup a filename in cache (to
avoid multiple command filter generation) and update 'usage' number
- new function: add_command_cache() add a new entry to cache (if
needed). If cache is full, replace the first less frequent used entry with
new
- new function: ext_get_command_cache() to get a command from cache
- new function: ext_flush_command_cache() remove all entry from
command cache (and mc_unlink() all filter file)
- changed function: exec_extension() - save the generated filters
properties into the command cache
* new argument: int *cmd_idx - set this to -1 or the cache index of
filter command if generated
* new argument: gboolean run_dialog - if TRUE function startup a new
mcviewer dialog
- changed function: regex_command() - now just call regex_command2()
with *cmd_idx = NULL and run_dialog = TRUE
- new function: regex_command2() - this is the old regex_command()
just changed a little bit - at the beginning check: there is a cached
command for the file, if any just use it
* new argument: int *cmd_idx - see exec_extension()
* new argument: gboolean run_dialog - see exec_extension()
2. filemanager/midnight.c
- changed function: do_nc() - flush command cache before exit
3. viewer/actions_cmd.c
- changed function: mcview_load_next_prev() - now it can use
regex_command2() to open files with external helpers
4. viewer/lib.c
- changed function: mcview_toggle_magic_mode - now it can use
regex_command2() to open files with external helpers
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:6>
* cc: gotar@… (added)
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:7>
* branch_state: no branch => on review
Comment:
The offered patch is overcomplicated. I implemented another decision.
Branch: 2968_viewer_next_prev_mode.
Initial changeset:4495957319bf14735e95841e37e9abb5559b2457
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:8>
* owner: => andrew_b
* status: new => assigned
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:9>
* status: assigned => accepted
* milestone: Future Releases => 4.8.9
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:10>
* votes: => slavazanko
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:11>
* votes: slavazanko => slavazanko angel_il
* branch_state: on review => approved
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:12>
* status: accepted => testing
* votes: slavazanko angel_il => committed-master
* resolution: => fixed
* branch_state: approved => merged
Comment:
Merged to master: [02265113cd5f99a5c2efbd249cd73ad1b04d4051].
{{{
git log --pretty=oneline 6cdfa25..0226511
}}}
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:13>
* status: testing => closed
--
Ticket URL: <http://www.midnight-commander.org/ticket/2968#comment:14>