comparison src/help.cc @ 542:682393bf54f7

[project @ 1994-07-22 04:41:52 by jwe]
author jwe
date Fri, 22 Jul 1994 04:44:45 +0000
parents 7ea224e713cd
children 94fd73d1a0bc
comparison
equal deleted inserted replaced
541:a8d5d1072d99 542:682393bf54f7
290 keyword_help (void) 290 keyword_help (void)
291 { 291 {
292 return keywords; 292 return keywords;
293 } 293 }
294 294
295 void
296 additional_help_message (ostrstream& output_buf)
297 {
298 output_buf
299 << "\n"
300 << "Additional help for builtin functions, operators, and variables\n"
301 << "is available in the on-line version of the manual.\n"
302 << "\n"
303 << "Use the command `help -i <topic>' to search the manual index.\n";
304 }
305
306 void
307 print_usage (const char *string, int just_usage)
308 {
309 ostrstream output_buf;
310
311 symbol_record *sym_rec = global_sym_tab->lookup (string, 0, 0);
312 if (sym_rec)
313 {
314 char *h = sym_rec->help ();
315 if (h && *h)
316 {
317 output_buf << "\n*** " << string << ":\n\n"
318 << h << "\n";
319
320 if (! just_usage)
321 additional_help_message (output_buf);
322 output_buf << ends;
323 maybe_page_output (output_buf);
324 }
325 }
326 }
327
295 static void 328 static void
296 help_syms_list (ostrstream& output_buf, help_list *list, 329 display_names_from_help_list (ostrstream& output_buf, help_list *list,
297 const char *desc) 330 const char *desc)
298 { 331 {
299 int count = 0; 332 int count = 0;
300 char **symbols = names (list, count); 333 char **symbols = names (list, count);
301 output_buf << "\n*** " << desc << ":\n\n"; 334 output_buf << "\n*** " << desc << ":\n\n";
302 if (symbols && count > 0) 335 if (symbols && count > 0)
303 list_in_columns (output_buf, symbols); 336 list_in_columns (output_buf, symbols);
304 delete [] symbols; 337 delete [] symbols;
305 } 338 }
306 339
307 static void 340 static void
341 display_symtab_names (ostrstream& output_buf, char **names,
342 int count, const char *desc)
343 {
344 output_buf << "\n*** " << desc << ":\n\n";
345 if (names && count > 0)
346 list_in_columns (output_buf, names);
347 }
348
349 static void
308 simple_help (void) 350 simple_help (void)
309 { 351 {
310 ostrstream output_buf; 352 ostrstream output_buf;
311 353
312 help_syms_list (output_buf, operator_help (), "operators"); 354 display_names_from_help_list (output_buf, operator_help (),
313 355 "operators");
314 help_syms_list (output_buf, keyword_help (), "reserved words"); 356
315 357 display_names_from_help_list (output_buf, keyword_help (),
316 help_syms_list (output_buf, builtin_text_functions_help (), 358 "reserved words");
317 "text functions (these names are also reserved)"); 359
318 360 #ifdef LIST_SYMBOLS
319 help_syms_list (output_buf, builtin_mapper_functions_help (), 361 #undef LIST_SYMBOLS
320 "mapper functions"); 362 #endif
321 363 #define LIST_SYMBOLS(type, msg) \
322 help_syms_list (output_buf, builtin_general_functions_help (), 364 do \
323 "general functions"); 365 { \
324 366 int count; \
325 help_syms_list (output_buf, builtin_variables_help (), 367 char **names = global_sym_tab->list (count, 1, type); \
326 "builtin variables"); 368 display_symtab_names (output_buf, names, count, msg); \
327 369 char **ptr = names; \
370 while (*ptr) \
371 delete [] *ptr++; \
372 delete [] names; \
373 } \
374 while (0)
375
376 // XXX FIXME XXX -- is this distinction needed?
377 LIST_SYMBOLS (symbol_def::TEXT_FUNCTION,
378 "text functions (these names are also reserved)");
379
380 LIST_SYMBOLS (symbol_def::MAPPER_FUNCTION, "mapper functions");
381
382 LIST_SYMBOLS (symbol_def::BUILTIN_FUNCTION, "general functions");
383
384 LIST_SYMBOLS (symbol_def::BUILTIN_VARIABLE, "builtin variables");
385
328 // Also need to list variables and currently compiled functions from 386 // Also need to list variables and currently compiled functions from
329 // the symbol table, if there are any. 387 // the symbol table, if there are any.
330 388
331 // Also need to search octave_path for script files. 389 // Also need to search octave_path for script files.
332 390
412 470
413 finish_info_session (initial_node, 0); 471 finish_info_session (initial_node, 0);
414 } 472 }
415 473
416 return status; 474 return status;
475 }
476
477 int
478 help_from_list (ostrstream& output_buf, const help_list *list,
479 const char *string, int usage)
480 {
481 char *name;
482 while ((name = list->name) != 0)
483 {
484 if (strcmp (name, string) == 0)
485 {
486 if (usage)
487 output_buf << "\nusage: ";
488 else
489 {
490 output_buf << "\n*** " << string << ":\n\n";
491 }
492
493 output_buf << list->help << "\n";
494
495 return 1;
496 }
497 list++;
498 }
499 return 0;
417 } 500 }
418 501
419 DEFUN_TEXT ("help", Fhelp, Shelp, -1, 1, 502 DEFUN_TEXT ("help", Fhelp, Shelp, -1, 1,
420 "help [-i] [topic ...]\n\ 503 "help [-i] [topic ...]\n\
421 \n\ 504 \n\