Ticket #2968 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

Raw/Parse and Format/Unformat do not work after C-f or C-b

Reported by: szaszg Owned by: andrew_b
Priority: major Milestone: 4.8.9
Component: mcview Version: master
Keywords: Cc: gotar@…
Blocked By: Blocking:
Branch state: merged Votes for changeset: committed-master

Description

  1. Open a man page (e.g. mc.1) in viewer (F3).
  2. Now with F8 and F9 we can play around Raw/Parsed? and Formatted/Unformatted? view
  3. After open next file (C-f) and than open previouse file (C-b), now we "view" the same file (e.g. mc.1)
  4. but F8 and F9 do not work anymore

Attachments

mc.2968.diff (12.0 KB) - added by szaszg 12 years ago.
magic mode uses regex_command()

Change History

comment:1 Changed 12 years ago 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...

comment:2 follow-up: ↓ 5 Changed 12 years ago 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

comment:3 follow-up: ↓ 4 Changed 12 years ago 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?

comment:4 in reply to: ↑ 3 Changed 12 years ago by szaszg

Replying to 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...

comment:5 in reply to: ↑ 2 Changed 12 years ago 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.

Changed 12 years ago by szaszg

magic mode uses regex_command()

comment:6 Changed 12 years ago 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

comment:7 Changed 12 years ago by gotar

  • Cc gotar@… added

comment:8 Changed 12 years ago by andrew_b

  • Branch state changed from no branch to on review

The offered patch is overcomplicated. I implemented another solution.

Branch: 2968_viewer_next_prev_mode.
Initial changeset:4495957319bf14735e95841e37e9abb5559b2457

Last edited 12 years ago by andrew_b (previous) (diff)

comment:9 Changed 12 years ago by slavazanko

  • Owner set to andrew_b
  • Status changed from new to assigned

comment:10 Changed 12 years ago by andrew_b

  • Status changed from assigned to accepted
  • Milestone changed from Future Releases to 4.8.9

comment:11 Changed 12 years ago by slavazanko

  • Votes for changeset set to slavazanko

comment:12 Changed 12 years ago by angel_il

  • Votes for changeset changed from slavazanko to slavazanko angel_il
  • Branch state changed from on review to approved

comment:13 Changed 12 years ago by andrew_b

  • Status changed from accepted to testing
  • Votes for changeset changed from slavazanko angel_il to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

Merged to master: [02265113cd5f99a5c2efbd249cd73ad1b04d4051].

git log --pretty=oneline 6cdfa25..0226511

comment:14 Changed 12 years ago by andrew_b

  • Status changed from testing to closed
Note: See TracTickets for help on using tickets.