home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1119 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  4.2 KB

  1. From: dupuy@hudson.cs.columbia.edu (Alexander Dupuy)
  2. Newsgroups: alt.sources
  3. Subject: Fourth unofficial patch for LESS
  4. Message-ID: <9004022019.AA01553@hudson.cs.columbia.edu>
  5. Date: 2 Apr 90 20:19:25 GMT
  6.  
  7. Here are some more patches which I posted earlier for less version 97 which
  8. have been applied to less version 123.  The original descriptions and the new
  9. patches follow.
  10.  
  11. Patrick J. Wolfe (pwolfe@kai.com) posted a patch which reimplemented a feature
  12. of less I sent to Casey Leedom and which might have been found in one of his
  13. "unofficial" distributions of less.  
  14.  
  15. Specifically, it caused less to automatically exit at the end of the first and
  16. only file, if it was less than one page (the idea being that you can see the
  17. whole thing without a pager).
  18.  
  19. It was pointed out that this causes some problems for people on workstations,
  20. or more generally anyone whose terminal goes into a special mode for programs
  21. using termcap.
  22.  
  23. The right way to fix this problem is to automatically disable the feature when
  24. less is running on a terminal with a special termcap mode.
  25.  
  26. Along with the patch that restores the old less behavior of quitting at the end
  27. of of the first and only file if it is on a single screen (ala more), this
  28. patch makes less even "more" convenient for empty files.  If there is nothing
  29. to display (since the first and only file is empty) this patch causes less to
  30. quit before it displays anything, and to leave the cursor where it already is.
  31. This will also happen if there are errors reading all input files.
  32.  
  33. *** /tmp/,RCSt1a00669    Mon Apr  2 15:44:48 1990
  34. --- main.c    Mon Apr  2 15:40:18 1990
  35. ***************
  36. *** 15,20 ****
  37. --- 15,21 ----
  38.   public HANDLE    curr_handle;
  39.   public POSITION    initial_pos;
  40.   public int    any_display;
  41. + public int    null_display;
  42.   public int    scroll;
  43.   public int    ac;
  44.   public char **    av;
  45. ***************
  46. *** 139,144 ****
  47. --- 140,157 ----
  48.       file = f;
  49.       ch_init(cbufs, 0);
  50.   
  51. +     /*
  52. +      * Ignore a single empty file if we quit at eof.
  53. +      */
  54. +     if (quit_at_eof && ac <= 1)
  55. +         if (ch_forw_get() == EOI)
  56. +         {
  57. +             file = -1;
  58. +             null_display = 1;
  59. +             return;
  60. +         }
  61. +         else (void) ch_back_get();
  62.       if (every_first_cmd != NULL)
  63.           first_cmd = every_first_cmd;
  64.   
  65. ***************
  66. *** 497,506 ****
  67.   #if LOGFILE
  68.       end_logfile();
  69.   #endif
  70. !     lower_left();
  71. !     clear_eol();
  72. !     deinit();
  73. !     flush();
  74.       raw_mode(0);
  75.       exit(0);
  76.   }
  77. --- 510,525 ----
  78.   #if LOGFILE
  79.       end_logfile();
  80.   #endif
  81. !     if (any_display)
  82. !     {
  83. !         lower_left();
  84. !         clear_eol();
  85. !     }
  86. !     if (any_display || null_display)
  87. !     {
  88. !         deinit();
  89. !         flush();
  90. !     }
  91.       raw_mode(0);
  92.       exit(0);
  93.   }
  94.  
  95. ===================================================================
  96.  
  97. *** /tmp/,RCSt1a00669    Mon Apr  2 15:44:49 1990
  98. --- prim1.c    Fri Mar 30 18:44:08 1990
  99. ***************
  100. *** 14,20 ****
  101. --- 14,22 ----
  102.   extern int top_scroll;
  103.   extern int quiet;
  104.   extern int sc_width, sc_height;
  105. + extern int te_init;
  106.   extern int quit_at_eof;
  107. + extern int ac;
  108.   extern int plusoption;
  109.   extern char *first_cmd;
  110.   #if TAGS
  111. ***************
  112. *** 192,197 ****
  113. --- 194,202 ----
  114.           eof_bell();
  115.       else if (do_repaint)
  116.           repaint();
  117. +     if (first_time && hit_eof && quit_at_eof && ac <= 1 &&
  118. +         (!te_init || quit_at_eof > 1))
  119. +           quit();
  120.       first_time = 0;
  121.       (void) currline(BOTTOM);
  122.   }
  123.  
  124. ===================================================================
  125.  
  126. *** /tmp/,RCSt1a00669    Mon Apr  2 15:44:51 1990
  127. --- screen.c    Fri Mar 30 18:43:06 1990
  128. ***************
  129. *** 55,60 ****
  130. --- 55,61 ----
  131.   
  132.   public int auto_wrap;        /* Terminal does \r\n when write past margin */
  133.   public int ignaw;        /* Terminal ignores \n immediately after wrap */
  134. + public int te_init;        /* Terminal uses ti and/or te for screen mode */
  135.   public int erase_char, kill_char; /* The user's erase and line-kill chars */
  136.   public int sc_width, sc_height;    /* Height & width of screen */
  137.   public int bo_width, be_width;    /* Printing width of boldface sequences */
  138. ***************
  139. *** 277,286 ****
  140. --- 278,291 ----
  141.       sc_init = tgetstr("ti", &sp);
  142.       if (sc_init == NULL)
  143.           sc_init = "";
  144. +     else
  145. +         te_init = 1;
  146.   
  147.       sc_deinit= tgetstr("te", &sp);
  148.       if (sc_deinit == NULL)
  149.           sc_deinit = "";
  150. +     else
  151. +         te_init = 1;
  152.   
  153.       sc_eol_clear = tgetstr("ce", &sp);
  154.       if (hard || sc_eol_clear == NULL || *sc_eol_clear == '\0')
  155.