commands.cc
/*
** edit_current_file - edit the current file in the DirList.
*/
edit the current file in the DirList.
edit the current file in the DirList .
static void edit_current_file(DirList *dl)
{
    const char *file = get_file_name(dl);
    if (is_directory(file))
    {
        if (strcmp(file, ".") == 0 || (strcmp(file, "..") == 0 &&
                                       strcmp(dl->name(), "/") == 0))
            return;
        if (!read_and_exec_perm(file))
        {
            message("need read & exec permissions to edit `%'", file);
            move_cursor(dl->savedYPos(), dl->savedXPos());
            synch_display();
            return;
        }
        dired(file);
    }
    else if (is_regular_file(file))
    {
        char *editor = getenv("EDITOR");
        if (editor == 0) editor = "vi";
        String cmd = String(editor) + " " + file;
         Clear screen and position cursor in case the editor doesn\'t
         do this itself.  This is primarily for those people who use
         non-fullscreen editors, such as `ed\', which don\'t do this.
        clear_display();
        move_to_message_line();
        synch_display();
        exec_with_system(cmd, 0);
         Re-read the listing line for this file
         and insert into the directory listing.
         This way, changes in file characteristics are
         reflected in the soon-to-be updated listing.
        reread_listing_line(dl, file);
        redisplay();
    }
    else
    {
        message("can only edit regular files and directories");
        move_cursor(dl->savedYPos(), dl->savedXPos());
        synch_display();
    }
}
static void edit_current_file ( DirList * dl ) { const char * file = get_file_name ( dl ) ; if ( is_directory ( file ) ) { if ( strcmp ( file , " " ) == 0 || ( strcmp ( file , " " ) == 0 && strcmp ( dl -> name ( ) , " " ) == 0 ) ) return ; if ( ! read_and_exec_perm ( file ) ) { message ( " " , file ) ; move_cursor ( dl -> savedYPos ( ) , dl -> savedXPos ( ) ) ; synch_display ( ) ; return ; } dired ( file ) ; } else if ( is_regular_file ( file ) ) { char * editor = getenv ( " " ) ; if ( editor == 0 ) editor = " " ; String cmd = String ( editor ) + " " + file ; clear_display ( ) ; move_to_message_line ( ) ; synch_display ( ) ; exec_with_system ( cmd , 0 ) ; reread_listing_line ( dl , file ) ; redisplay ( ) ; } else { message ( " " ) ; move_cursor ( dl -> savedYPos ( ) , dl -> savedXPos ( ) ) ; synch_display ( ) ; } }
edit_current_file - edit the current file in the DirList.
edit_current_file - edit the current file in the DirList .
// // Clear screen and position cursor in case the editor doesn\'t // do this itself.  This is primarily for those people who use // non-fullscreen editors, such as `ed\', which don\'t do this. // // // Re-read the listing line for this file // and insert into the directory listing. // This way, changes in file characteristics are // reflected in the soon-to-be updated listing. //