home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / BRIEFINF.ZIP / INFHELP.CB next >
Text File  |  1992-03-15  |  3KB  |  142 lines

  1. /*                                                                          */
  2. /*       infhelp.cb                                                         */
  3. /*                                                                          */
  4. /*       Interface the IBM INF help subsystem supplied with the OS/2 2.0    */
  5. /*       toolkit into brief 3.x                                             */
  6. /*                                                                          */
  7. /*       Marc A. Ache'                                                      */
  8. /*                                                                          */
  9. /*       This macro calls to the view program to invoke a window that       */
  10. /*       descibes the queried function or topic.                            */
  11.  
  12. infhelp (...)
  13. {
  14.    assign_to_key ("<Alt-q>", "do_infhelp");
  15. }
  16.  
  17. do_infhelp (...)
  18. {
  19.    string   _hlptxt;
  20.  
  21.    int   ret_code;
  22.  
  23.    global   _hlptxt;
  24.  
  25.    /*  check if path is the root                                            */
  26.  
  27.    if ( inq_marked() )
  28.    {  
  29.       _hlptxt = _armgt();
  30.    }
  31.    else
  32.    {
  33.       _hlptxt = _getarg();
  34.    }
  35.  
  36.    if ( _hlptxt == "" )
  37.    {
  38.       if (!get_parm(0, _hlptxt, "Find Topic: ", NULL, _hlptxt))
  39.          return;
  40.    }
  41.  
  42.    message("Searching for \"%s\"...", _hlptxt);
  43.    ret_code = dos("VIEW %PMREF%+%PROGREF20% " + _hlptxt + " >& nul", 1 ); 
  44.    message("");                                                   
  45. }
  46.           
  47. /*                                                                          */
  48. /*    Return marked string                                                  */
  49. /*                                                                          */
  50.  
  51. _armgt (...)
  52. {
  53.    string   mtxt;
  54.  
  55.    int   start_line,
  56.          end_line,
  57.          start_col,
  58.          end_col,
  59.          temp_int;
  60.  
  61.    if (inq_marked ())
  62.    {
  63.       save_position ();
  64.       inq_position (end_line, end_col);
  65.       swap_anchor ();
  66.       inq_position (start_line, start_col);
  67.       raise_anchor ();
  68.  
  69.       /*    If the starting column is greater than the ending               */
  70.       /*    column, swap the variables                                      */
  71.  
  72.       if (start_col > end_col)
  73.       {
  74.          temp_int = start_col;
  75.          start_col = end_col;
  76.          end_col = temp_int;
  77.          move_abs (0, start_col);
  78.       }
  79.  
  80.       if (start_line == end_line)
  81.       {
  82.          temp_int = (end_col - start_col) + 1;
  83.          mtxt = read (temp_int);
  84.       }
  85.       else
  86.          mtxt = read ();
  87.  
  88.       restore_position ();
  89.    }
  90.    else
  91.       mtxt = "";
  92.  
  93.    returns mtxt;
  94. }
  95.  
  96.  
  97. _getarg (...)
  98. {
  99.    string   mtxt;
  100.    int      size;
  101.  
  102.    save_position ();
  103.  
  104.    mtxt = read(1);
  105.  
  106.    if ( mtxt == " " )
  107.       prev_char(1);                        
  108.  
  109.    if ( search_back( " |(|\t|\n|!", 1 ) == 2 )
  110.    {
  111.       next_char();      
  112.    }
  113.    else
  114.    {
  115.       move_abs(0);
  116.    }
  117.  
  118.    drop_anchor();
  119.  
  120.    if ( search_fwd( " |(|\t|\n", 1 ) == 2 )
  121.    {
  122.       prev_char();      
  123.    }
  124.  
  125.    size = inq_mark_size();
  126.    
  127.    prev_char( size-1 );   
  128.  
  129.    mtxt = read(size);
  130.  
  131.    raise_anchor();
  132.  
  133.    restore_position ();
  134.  
  135.    mtxt = trim(mtxt);
  136.  
  137.    return mtxt;
  138. }
  139.  
  140.  
  141.         
  142.