home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / AP / JED / JED097-1.TAR / jed / lib / most.sl < prev    next >
Encoding:
Text File  |  1994-12-12  |  3.3 KB  |  127 lines

  1. %%
  2. %%  Most/more/less file viewing
  3. %%  
  4.  
  5. define most_edit ()
  6. {
  7.    set_readonly(0);
  8.    getbuf_info(); pop(); pop(); pop(); 
  9.    file_type(); runhooks("mode_hook");
  10.    set_status_line(Null_String, 0);
  11. }
  12.  
  13.  
  14. . (
  15. .    [flags]
  16. .    most_edit
  17. .    getbuf_info =flags pop pop pop
  18. .    flags 1 & {whatbuf delbuf} !if
  19. .    otherwindow
  20. .    "Done." message 
  21. . ) most_exit_most
  22.  
  23. . (
  24. .  "SPC:pg dn, DEL:pg up, /:search forw, ?:search back, q:quit, e:edit, h:this help"
  25. .  message
  26. . ) most_help
  27.  
  28. . [Most_Map] "Most" =Most_Map
  29. . Most_Map keymap_p
  30. .  {  
  31. .     Most_Map make_keymap %% need a make sparse map!
  32. .     'A' 'z' 1 {char Most_Map undefinekey} _for
  33. .     "page_up"    "^?" Most_Map definekey
  34. .     "page_down"  " "  Most_Map definekey
  35. .     "most_exit_most" "q"  Most_Map definekey
  36. .     "most_edit"    "e"    Most_Map definekey
  37. .     "most_find_f" "s" Most_Map definekey
  38. .     "most_find_f" "S" Most_Map definekey
  39. .     "most_find_f" "/" Most_Map definekey
  40. .     "most_find_b" "?" Most_Map definekey
  41. .     "most_find_n" "N" Most_Map definekey
  42. .     "most_help"    "h"    Most_Map definekey
  43. .     "eob" "B" Most_Map definekey
  44. .     "bob" "T" Most_Map definekey
  45. .  }
  46. . !if
  47.  
  48. %!% Emulates MOST fileviewer
  49. %!% The following keys are defined:
  50. %!% SPACE            next screen
  51. %!% DELETE           previous screen
  52. %!% /                search_forward
  53. %!% ?                search_backward
  54. %!% n                find next occurrence
  55. %!% q                quit most mode  (usually kills buffer if not modified)
  56. %!% e                edit buffer
  57. %!% h                help summary
  58. %!% t                Top of Buffer
  59. %!% b                End of Buffer
  60. define most_mode ()
  61. {
  62. .   Most_Map use_keymap
  63. .   1 set_readonly
  64. .   Most_Map 0 setmode
  65. .   " MOST : press 'h' for help.   %b    (%p)" 0 set_status_line
  66. %.   most_help
  67. }
  68.   
  69. . [most_dir] 1 =most_dir
  70.  
  71. . ( [r]
  72. .   LAST_SEARCH int 0 ==
  73. .     { "Find What?" error}
  74. .     { LAST_SEARCH
  75. .       most_dir 1 == { 1 right =r fsearch }{ 0 =r bsearch } else
  76. .       { "Not Found." error 
  77. .         r left pop
  78. .       } !if
  79. .     } else
  80. . ) most_find_n
  81.  
  82.  
  83. . ( -1 =most_dir search_backward) most_find_b
  84. . ( 1 =most_dir search_forward) most_find_f
  85.  
  86. . [Most_Min_Arg] 
  87. . [Most_Current_Arg] 
  88. %%% Emulate MOST fileviewer.
  89. define run_most (arg)
  90. {
  91.    Most_Min_Arg = arg;
  92.    Most_Current_Arg = arg;
  93.  
  94.    if (arg != MAIN_ARGC) pop (find_file (command_line_arg (arg)));
  95.    most_mode ();
  96.    definekey ("most_next_file", ":N", Most_Map);
  97.    definekey ("exit_jed", "q", Most_Map);
  98.    definekey ("exit_jed", "Q", Most_Map);
  99.    definekey ("most_exit_most", ":Q", Most_Map);
  100.    help_for_help_string = 
  101.    "Most Mode: SPC- next screen, DEL- prev screen, Q Quit, :n next file, :Q edit";
  102. }
  103.  
  104. . (
  105. .   [f file dir] 1 =dir
  106. .   {
  107. .      Most_Current_Arg dir + =Most_Current_Arg
  108. .      Most_Current_Arg MAIN_ARGC == {Most_Min_Arg =Most_Current_Arg} if
  109. .      Most_Current_Arg Most_Min_Arg < {MAIN_ARGC 1 - =Most_Current_Arg} if
  110.      
  111. .      Most_Current_Arg command_line_arg =file
  112. .      "Next File (Use Arrow keys to select): " file strcat flush
  113. .      get_key_function =f
  114. .      f strlen
  115. .       {
  116. .          pop % pops off second return value of get_key_function
  117. .      "previous_line_cmd" f strcmp {1 =dir continue} !if
  118. .      "next_line_cmd" f strcmp {-1 =dir continue} !if
  119. .      break
  120. .       }{
  121. .      beep
  122. .       } else
  123. .    } forever
  124. .   file find_file pop " " message
  125. .   most_mode
  126. . ) most_next_file
  127.