"Fossies" - the Fresh Open Source Software Archive 
Member "most-5.2.0/src/help.c" (4 Aug 2022, 5150 Bytes) of package /linux/misc/most-5.2.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "help.c" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
5.1.0_vs_5.2.0.
1 /*
2 This file is part of MOST.
3
4 Copyright (c) 1991, 1999, 2002, 2005-2021, 2022 John E. Davis
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc., 675
18 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 #include "config.h"
21 #include <stdio.h>
22 #include <string.h>
23
24 #ifdef VMS
25 # include <stat.h>
26 #else
27 # include <sys/types.h>
28 # include <sys/stat.h>
29 #endif
30
31 #ifdef HAVE_STDLIB_H
32 # include <stdlib.h>
33 #endif
34
35 #include <slang.h>
36 #include "jdmacros.h"
37
38 #include "most.h"
39 #include "window.h"
40 #include "file.h"
41 #include "display.h"
42 #include "line.h"
43 #include "keym.h"
44 #include "sysdep.h"
45
46 /* This section provided by Mats Akerberg (mats@efd.lth.se) */
47
48 static char *help[] =
49 {
50 "Quitting:",
51 " Q Quit MOST.",
52 " :N,:n Quit this file and view next. ",
53 " (Use UP/DOWN arrow keys to select next file.)",
54 "Movement:",
55 " SPACE, D *Scroll down one Screen.",
56 " U, BACKSPACE *Scroll Up one screen.",
57 " RETURN, DOWN *Move Down one line.",
58 " UP *Move Up one line.",
59 " T Goto Top of File.",
60 " B Goto Bottom of file.",
61 " > , TAB Scroll Window right",
62 " < Scroll Window left",
63 " RIGHT Scroll Window left by 1 column",
64 " LEFT Scroll Window right by 1 column",
65 " J, G Goto line.",
66 " % Goto percent.",
67 "Window Commands:",
68 " Ctrl-X 2, Ctrl-W 2 Split window.",
69 " Ctrl-X 1, Ctrl-W 1 Make only one window.",
70 " O, Ctrl-X O Move to other window.",
71 " Ctrl-X 0 Delete Window.",
72 "Searching:",
73 " S, f, / *Search forward",
74 " ? *Search Backward",
75 " N *Find next in current search direction.",
76 "Miscellaneous:",
77 " W Toggle width between 80 and 132 char mode.",
78 " Ctrl-X Ctrl-F Read a file from disk",
79 " R, Ctrl-R Redraw Screen.",
80 " F Simulate tail -f mode",
81 " :o Toggle options: b-binary, w-wrap, t-tab",
82 " E Edit file. Uses MOST_EDITOR and EDITOR",
83 " environment variables.",
84 "*Note: This command may be repeated `n' times By entering a number then",
85 " the command key, e.g., '5 SPACE' moves 5 screens forward.",
86 NULL
87 };
88
89 static void most_do_help_text (void)
90 {
91 char **p = help, *sect = NULL;
92 int r;
93
94 while (*p != NULL)
95 {
96 SLsmg_cls ();
97
98 r = 0;
99 SLsmg_gotorc (0, 0);
100
101 if ((sect != NULL) && (**p == ' '))
102 {
103 most_tt_bold_video ();
104 SLsmg_gotorc (r, 0);
105 SLsmg_write_string (sect);
106 most_tt_normal_video ();
107 SLsmg_write_string (" (continued)");
108 r += 2;
109 }
110 else sect = NULL;
111
112 while (r < SLtt_Screen_Rows - 1)
113 {
114 if (*p == NULL) break;
115
116 if (**p != ' ')
117 {
118 if (((r + 5) > SLtt_Screen_Rows)
119 && (**p != '*'))
120 {
121 sect = NULL;
122 break;
123 }
124
125 if (sect != NULL)
126 {
127 r++;
128 }
129
130 if (**p != '*')
131 {
132 sect = *p;
133 most_tt_bold_video ();
134 }
135 else sect = NULL;
136 }
137 SLsmg_gotorc (r, 0);
138 SLsmg_write_string (*p);
139
140 if ((**p != ' ') && (**p != '*'))
141 {
142 most_tt_normal_video ();
143 r++;
144 }
145 p++;
146 r++;
147 }
148
149 SLsmg_gotorc (r, 0);
150
151 most_tt_reverse_video();
152 SLsmg_write_string("Press any key to continue.");
153 most_tt_normal_video();
154
155 SLsmg_refresh ();
156
157 most_getkey ();
158 }
159
160 most_redraw_display();
161 }
162
163 static void most_do_help_file (char *helpfile)
164 {
165 char *buf_name;
166 FILE *fp;
167
168 buf_name = "*help*";
169
170 #ifdef MOST_HELPFILE
171 if (helpfile == NULL) helpfile = MOST_HELPFILE;
172 #endif
173
174 if (helpfile != NULL)
175 {
176 if (most_file_visible(buf_name)) return;
177
178 /* See if we can open it */
179 if (NULL != (fp = fopen (helpfile, "r")))
180 {
181 fclose (fp);
182 if (!most_split_window())
183 {
184 most_message("Two many windows.",1);
185 return;
186 }
187 most_update_status(); /* create status line of prev. window */
188 most_other_window(1);
189 (void) most_find_file(helpfile);
190 strcpy(Most_Buf->file, buf_name);
191 Most_B_Opt = 0;
192 most_window_buffer ();
193 most_redraw_window ();
194 most_update_status ();
195 return;
196 }
197 }
198
199 most_do_help_text ();
200 }
201
202 void most_do_help_command(void)
203 {
204 most_do_help_file (getenv ("MOST_HELP"));
205 }
206