vi: save/restore screen upon invocation
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 11 Jun 2012 11:53:26 +0000 (13:53 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 11 Jun 2012 11:53:26 +0000 (13:53 +0200)
function                                             old     new   delta
vi_main                                              253     273     +20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
editors/vi.c

index 459f374f76970240bbba4462ce78580b795dbb20..e09e0d9c794843067bb8b2f273a05ea93f541541 100644 (file)
@@ -598,11 +598,15 @@ int vi_main(int argc, char **argv)
        //----- This is the main file handling loop --------------
        save_argc = argc;
        optind = 0;
+       // "Save cursor, use alternate screen buffer, clear screen"
+       write1("\033[?1049h");
        while (1) {
                edit_file(argv[optind]); /* param might be NULL */
                if (++optind >= argc)
                        break;
        }
+       // "Use normal screen buffer, restore cursor"
+       write1("\033[?1049l");
        //-----------------------------------------------------------
 
        return 0;