Ticket #2156: mc1.patch

File mc1.patch, 13.0 KB (added by andrew_b, 15 years ago)
  • src/cmd.c

    diff -u -r -w mc-4.7.1-org/src/cmd.c mc-4.7.1-viewertoeditor/src/cmd.c
    old new  
    117117{ 
    118118    static const char *viewer = NULL; 
    119119    int move_dir = 0; 
     120    int run_editor = 0; 
    120121 
    121122 
    122123    if (plain_view) { 
     
    136137        mcview_default_hex_mode = 0; 
    137138        mcview_default_nroff_flag = 0; 
    138139        mcview_default_magic_flag = 0; 
    139         mcview_viewer (NULL, filename, &move_dir, start_line); 
     140        mcview_viewer (NULL, filename, &move_dir, start_line, &run_editor); 
    140141        if (changed_hex_mode && !mcview_altered_hex_mode) 
    141142            mcview_default_hex_mode = 1; 
    142143        if (changed_nroff_flag && !mcview_altered_nroff_flag) 
     
    144145        if (changed_magic_flag && !mcview_altered_magic_flag) 
    145146            mcview_default_magic_flag = 1; 
    146147        repaint_screen (); 
     148        if (run_editor) { 
     149                do_edit_at_line (filename, start_line, 1); 
     150                repaint_screen (); 
     151        } 
    147152        return move_dir; 
    148153    } 
    149154    if (internal) { 
     
    156161            strcpy (view_entry, "View"); 
    157162 
    158163        if (regex_command (filename, view_entry, &move_dir) == 0) { 
    159             mcview_viewer (NULL, filename, &move_dir, start_line); 
     164            mcview_viewer (NULL, filename, &move_dir, start_line, &run_editor); 
    160165            repaint_screen (); 
    161166        } 
    162167    } else { 
     
    169174        } 
    170175        execute_with_vfs_arg (viewer, filename); 
    171176    } 
     177    if (run_editor) { 
     178        do_edit_at_line (filename, start_line, 1); 
     179        repaint_screen (); 
     180    } 
    172181    return move_dir; 
    173182} 
    174183 
     
    289298    if (!command) 
    290299        return; 
    291300 
    292     mcview_viewer (command, "", NULL, 0); 
     301    mcview_viewer (command, "", NULL, 0, NULL); 
    293302 
    294303    g_free (command); 
    295304} 
    296305 
    297306void 
    298 do_edit_at_line (const char *what, int start_line) 
     307do_edit_at_line (const char *what, int start_line, int no_center) 
    299308{ 
    300309    static const char *editor = NULL; 
    301310 
    302311#ifdef USE_INTERNAL_EDIT 
    303312    if (use_internal_edit) 
    304         edit_file (what, start_line); 
     313        edit_file (what, start_line, no_center); 
    305314    else 
    306315#else 
    307316    (void) start_line; 
     
    321330static void 
    322331do_edit (const char *what) 
    323332{ 
    324     do_edit_at_line (what, 0); 
     333    do_edit_at_line (what, 0, 0); 
    325334} 
    326335 
    327336void 
  • src/cmddef.h

    diff -u -r -w mc-4.7.1-org/src/cmddef.h mc-4.7.1-viewertoeditor/src/cmddef.h
    old new  
    274274#define CK_ViewPrevFile                 5025 
    275275#define CK_ViewToggleRuler              5026 
    276276#define CK_ViewToggleHexNavMode         5027 
     277#define CK_ViewRunEditor                5028 
    277278 
    278279/* Tree */ 
    279280#define CK_TreeHelp                     6001 
  • src/cmd.h

    diff -u -r -w mc-4.7.1-org/src/cmd.h mc-4.7.1-viewertoeditor/src/cmd.h
    old new  
    2424void view_file_cmd (void); 
    2525void view_simple_cmd (void); 
    2626void filtered_view_cmd (void); 
    27 void do_edit_at_line (const char *what, int start_line); 
     27void do_edit_at_line (const char *what, int start_line, int no_center); 
    2828void edit_cmd (void); 
    2929void edit_cmd_new (void); 
    3030void copy_cmd (void); 
  • src/editor/edit.c

    diff -u -r -w mc-4.7.1-org/src/editor/edit.c mc-4.7.1-viewertoeditor/src/editor/edit.c
    old new  
    709709        line = edit->curs_line; 
    710710    } 
    711711    edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1)); 
     712    if (!edit->no_center) 
    712713    edit_move_display (edit, line - (edit->num_widget_lines / 2)); 
     714    else 
     715         edit_move_display (edit, line); 
    713716} 
    714717 
    715718/* Save cursor position in the file */ 
     
    760763 */ 
    761764WEdit * 
    762765edit_init (WEdit *edit, int lines, int columns, const char *filename, 
    763            long line) 
     766           long line, int no_center) 
    764767{ 
    765768    int to_free = 0; 
    766769    option_auto_syntax = 1; /* Resetting to auto on every invokation */ 
     
    821824    } 
    822825    edit->utf8 = 0; 
    823826    edit->converter = str_cnv_from_term; 
     827    edit->no_center = no_center ? 1 : 0; 
    824828#ifdef HAVE_CHARSET 
    825829    { 
    826830    const char *cp_id = NULL; 
     
    915919    int columns = edit->num_widget_columns; 
    916920 
    917921    edit_clean (edit); 
    918     return (edit_init (edit, lines, columns, "", 0) != NULL); 
     922    return (edit_init (edit, lines, columns, "", 0, 0) != NULL); 
    919923} 
    920924 
    921925/* 
     
    933937 
    934938    e = g_malloc0 (sizeof (WEdit)); 
    935939    e->widget = edit->widget; 
    936     if (!edit_init (e, lines, columns, filename, 0)) { 
     940    if (!edit_init (e, lines, columns, filename, 0, 0)) { 
    937941        g_free (e); 
    938942        return 0; 
    939943    } 
     
    958962 
    959963    e = g_malloc0 (sizeof (WEdit)); 
    960964    e->widget = edit->widget; 
    961     if (!edit_init (e, lines, columns, filename, line)) { 
     965    if (!edit_init (e, lines, columns, filename, line, 0)) { 
    962966        g_free (e); 
    963967        return 0; 
    964968    } 
  • src/editor/edit.h

    diff -u -r -w mc-4.7.1-org/src/editor/edit.h mc-4.7.1-viewertoeditor/src/editor/edit.h
    old new  
    6767void edit_stack_init (void); 
    6868void edit_stack_free (void); 
    6969 
    70 int edit_file (const char *_file, int line); 
     70int edit_file (const char *_file, int line, int no_center); 
    7171 
    7272const char *edit_get_file_name (const WEdit *edit); 
    7373int edit_get_curs_col (const WEdit *edit); 
  • src/editor/edit-impl.h

    diff -u -r -w mc-4.7.1-org/src/editor/edit-impl.h mc-4.7.1-viewertoeditor/src/editor/edit-impl.h
    old new  
    211211int edit_save_confirm_cmd (WEdit * edit); 
    212212int edit_save_as_cmd (WEdit * edit); 
    213213WEdit *edit_init (WEdit *edit, int lines, int columns, 
    214                   const char *filename, long line); 
     214                  const char *filename, long line, int no_center); 
    215215int edit_clean (WEdit * edit); 
    216216int edit_ok_to_exit (WEdit *edit); 
    217217int edit_renew (WEdit * edit); 
  • src/editor/editwidget.c

    diff -u -r -w mc-4.7.1-org/src/editor/editwidget.c mc-4.7.1-viewertoeditor/src/editor/editwidget.c
    old new  
    227227} 
    228228 
    229229int 
    230 edit_file (const char *_file, int line) 
     230edit_file (const char *_file, int line, int no_center) 
    231231{ 
    232232    static gboolean made_directory = FALSE; 
    233233    Dlg_head *edit_dlg; 
     
    238238        g_free (dir); 
    239239    } 
    240240 
    241     wedit = edit_init (NULL, LINES - 2, COLS, _file, line); 
     241    wedit = edit_init (NULL, LINES - 2, COLS, _file, line, no_center); 
    242242 
    243243    if (wedit == NULL) 
    244244        return 0; 
  • src/editor/edit-widget.h

    diff -u -r -w mc-4.7.1-org/src/editor/edit-widget.h mc-4.7.1-viewertoeditor/src/editor/edit-widget.h
    old new  
    7474    unsigned int delete_file:1; /* New file, needs to be deleted unless modified */ 
    7575    unsigned int highlight:1;   /* There is a selected block */ 
    7676    unsigned int utf8:1;        /* It's multibyte file codeset */ 
     77    unsigned int no_center:1;   /* Do not move edit line to center when create editor window */ 
     78 
    7779    long prev_col;              /* recent column position of the cursor - used when moving 
    7880                                   up or down past lines that are shorter than the current line */ 
    7981    long curs_line;             /* line number of the cursor. */ 
     
    126128    int extmod; 
    127129 
    128130    char *labels[10]; 
    129  
    130131}; 
    131132 
    132133#endif                          /* MC_EDIT_WIDGET_H */ 
  • src/ext.c

    diff -u -r -w mc-4.7.1-org/src/ext.c mc-4.7.1-viewertoeditor/src/ext.c
    old new  
    252252         * into view 
    253253         */ 
    254254        if (written_nonspace) { 
    255             mcview_viewer (cmd, filename, move_dir, start_line); 
     255            mcview_viewer (cmd, filename, move_dir, start_line, NULL); 
    256256            unlink (file_name); 
    257257        } else { 
    258             mcview_viewer (NULL, filename, move_dir, start_line); 
     258            mcview_viewer (NULL, filename, move_dir, start_line, NULL); 
    259259        } 
    260260        if (changed_hex_mode && !mcview_altered_hex_mode) 
    261261            mcview_default_hex_mode = def_hex_mode; 
  • src/find.c

    diff -u -r -w mc-4.7.1-org/src/find.c mc-4.7.1-viewertoeditor/src/find.c
    old new  
    10291029 
    10301030    fullname = make_fullname (dir, filename); 
    10311031    if (edit) 
    1032         do_edit_at_line (fullname, line); 
     1032        do_edit_at_line (fullname, line, 0); 
    10331033    else 
    10341034        view_file_at_line (fullname, unparsed_view, use_internal_view, line); 
    10351035    g_free (fullname); 
  • src/keybind.c

    diff -u -r -w mc-4.7.1-org/src/keybind.c mc-4.7.1-viewertoeditor/src/keybind.c
    old new  
    249249    { "ViewPrevFile",                    CK_ViewPrevFile }, 
    250250    { "ViewToggleRuler",                 CK_ViewToggleRuler }, 
    251251    { "ViewToggleHexNavMode",            CK_ViewToggleHexNavMode }, 
     252    { "ViewRunEditor",                   CK_ViewRunEditor }, 
    252253 
    253254    /* help */ 
    254255    { "HelpHelp",                        CK_HelpHelp }, 
     
    514515    { ALT ('e'),   CK_SelectCodepage,        "M-e" }, 
    515516    { XCTRL ('o'), CK_ShowCommandLine,       "C-o" }, 
    516517 
     518    { KEY_F (14),  CK_ViewRunEditor,        "S-F4" }, 
     519 
    517520    { 0, CK_Ignore_Key, "" } 
    518521}; 
    519522 
  • src/main.c

    diff -u -r -w mc-4.7.1-org/src/main.c mc-4.7.1-viewertoeditor/src/main.c
    old new  
    18271828    } 
    18281829#ifdef USE_INTERNAL_EDIT 
    18291830    else 
    1830         edit_file (edit_one_file, edit_one_file_start_line); 
     1831        edit_file (edit_one_file, edit_one_file_start_line, 0); 
    18311832#endif                          /* USE_INTERNAL_EDIT */ 
    18321833    midnight_shutdown = 1; 
    18331834    done_mc (); 
  • src/user.c

    diff -u -r -w mc-4.7.1-org/src/user.c mc-4.7.1-viewertoeditor/src/user.c
    old new  
    702702    chmod (file_name, S_IRWXU); 
    703703    if (run_view) { 
    704704        run_view = 0; 
    705         mcview_viewer (file_name, NULL, &run_view, 0); 
     705        mcview_viewer (file_name, NULL, &run_view, 0, NULL); 
    706706    } else { 
    707707        /* execute the command indirectly to allow execution even 
    708708         * on no-exec filesystems. */ 
  • src/viewer/actions_cmd.c

    diff -u -r -w mc-4.7.1-org/src/viewer/actions_cmd.c mc-4.7.1-viewertoeditor/src/viewer/actions_cmd.c
    old new  
    439439        if (!mcview_is_in_panel (view)) 
    440440            view->move_dir = (command == CK_ViewNextFile) ? 1 : -1; 
    441441        /* fallthrough */ 
     442    case CK_ViewRunEditor: 
     443        view->run_editor = 1; 
    442444    case CK_ViewQuit: 
    443445        if (mcview_ok_to_quit (view)) 
    444446            view->want_to_quit = TRUE; 
  • src/viewer/internal.h

    diff -u -r -w mc-4.7.1-org/src/viewer/internal.h mc-4.7.1-viewertoeditor/src/viewer/internal.h
    old new  
    191191    struct mcview_nroff_struct *search_nroff_seq; 
    192192 
    193193    int search_numNeedSkipChar; 
     194 
     195    int run_editor; 
    194196} mcview_t; 
    195197 
    196198typedef struct mcview_nroff_struct 
  • src/viewer/mcviewer.c

    diff -u -r -w mc-4.7.1-org/src/viewer/mcviewer.c mc-4.7.1-viewertoeditor/src/viewer/mcviewer.c
    old new  
    257257    view->update_steps = 0; 
    258258    view->update_activate = 0; 
    259259 
     260    view->run_editor = 0; 
     261 
    260262    if (mcview_default_hex_mode) 
    261263        mcview_toggle_hex_mode (view); 
    262264    if (mcview_default_nroff_flag) 
     
    275277 
    276278/* Real view only */ 
    277279int 
    278 mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line) 
     280mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line, int * run_editor) 
    279281{ 
    280282    gboolean succeeded; 
    281283    mcview_t *lc_mcview; 
     
    296298        run_dlg (view_dlg); 
    297299        if (move_dir_p) 
    298300            *move_dir_p = lc_mcview->move_dir; 
     301        if (run_editor) 
     302            *run_editor = lc_mcview->run_editor; 
    299303    } 
    300304    else 
    301305    { 
  • src/viewer/mcviewer.h

    diff -u -r -w mc-4.7.1-org/src/viewer/mcviewer.h mc-4.7.1-viewertoeditor/src/viewer/mcviewer.h
    old new  
    4343 * point to a variable that will receive the direction in which the user 
    4444 * wants to move (-1 = previous file, 1 = next file, 0 = do nothing). 
    4545 */ 
    46 extern int mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line); 
     46extern int mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line, int * run_editor); 
    4747 
    4848extern gboolean mcview_load (struct mcview_struct *, const char *, const char *, int); 
    4949