home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / DBRIEF.ZIP / SOURCE / GRAPHICS.M < prev    next >
Encoding:
Text File  |  1991-03-21  |  11.5 KB  |  511 lines

  1. ;dBRIEF Graphics  - v3.10
  2. ;Copyright (c) 1991 - Global Technologies Corporation
  3. ;ALL RIGHTS RESERVED
  4. #include "dbrief.h"
  5. (macro draw
  6.     (
  7.         (string            draw_temp_str
  8.         )
  9.         (if (get_parm 0 draw_temp_str)
  10.             (switch (upper (substr draw_temp_str 1 1))
  11.                 "F"
  12.                     (_frame)
  13.                 "C"
  14.                     (_cursor)
  15.                 "L"
  16.                     (_line)
  17.                 "B"
  18.                     (_box)
  19.                 "A"
  20.                     (_area)
  21.              )
  22.         ;else
  23.             (
  24.                 (= temp_str "NULL")
  25.                 (_pick_menu (search_path (inq_environment dbr_mnu_path) "graphics.mnu") "Graphics" 38 09 65 02)
  26.                 (if (!= temp_str "NULL")
  27.                     (execute_macro temp_str)
  28.                 )
  29.             )
  30.         )
  31.     )
  32. )
  33. (macro _frame
  34.     (
  35.         (int                width
  36.                             height
  37.                             beg_line
  38.                             beg_col
  39.                             end_line
  40.                             end_col
  41.                             top_line
  42.                             current_line
  43.                             current_column
  44.         )
  45.         (string            temp_str1
  46.                             temp_str2
  47.         )
  48.         (if (== (inq_marked) 2)
  49.             (
  50.                 (drop_bookmark 5 "y")
  51.                 (top_of_window)
  52.                 (inq_position top_line NULL)
  53.                 (goto_bookmark 5)
  54.                 (inq_marked beg_line beg_col end_line end_col)
  55.                 (-= beg_line top_line)
  56.                 (-= end_line top_line)
  57.                 (raise_anchor)
  58.                 (message "Generating frame, stand by...")
  59.                 (= width (- end_col (+ beg_col 1)))
  60.                 (= height (- end_line beg_line))
  61.                 (-= height 1)
  62.                 (top_of_buffer)
  63.                 (if (search_fwd "~frame~" 1 0)
  64.                     (
  65.                         (inq_position NULL current_column)
  66.                         (delete_to_eol)
  67.                     )
  68.                 ;else
  69.                     (move_abs beg_line 1)
  70.                 )
  71.                 (= temp_str1 (_frame_component 1 beg_line beg_col (substr ul_char dbr_graphics 1) NULL current_column))
  72.                 (= temp_str2 (_frame_component 2 NULL NULL (+ (_replicate (substr hr_char dbr_graphics 1) width) (substr ur_char dbr_graphics 1)) NULL current_column))
  73.                 (move_abs 0 current_column)
  74.                 (insert (+ temp_str1 temp_str2))
  75.                 (= temp_int 0)
  76.                 (while (<= (++ temp_int) height)
  77.                     (
  78.                         (+= beg_line 1)
  79.                         (if (== width 78)
  80.                             (= temp_str1 (_frame_component 3 beg_line beg_col (substr vr_char dbr_graphics 1) temp_int current_column))
  81.                         ;else
  82.                             (= temp_str1 (_frame_component 4 beg_line beg_col (substr vr_char dbr_graphics 1) temp_int current_column))
  83.                         )
  84.                         (= temp_str2 (_frame_component 5 NULL NULL (+ (_replicate " " width) (substr vr_char dbr_graphics 1)) temp_int current_column))
  85.                         (move_abs 0 current_column)
  86.                         (insert (+ temp_str1 temp_str2))
  87.                     )
  88.                 )
  89.                 (+= beg_line 1)
  90.                 (if (== width 78)
  91.                     (= temp_str1 (_frame_component 3 beg_line beg_col (substr ll_char dbr_graphics 1) NULL current_column))
  92.                 ;else
  93.                     (= temp_str1 (_frame_component 4 beg_line beg_col (substr ll_char dbr_graphics 1) NULL current_column))
  94.                 )
  95.                 (= temp_str2 (_frame_component 5 NULL NULL (+ (_replicate (substr hr_char dbr_graphics 1) width) (substr lr_char dbr_graphics 1)) NULL current_column))
  96.                 (move_abs 0 current_column)
  97.                 (insert (+ temp_str1 temp_str2))
  98.                 (move_abs 0 current_column)
  99.                 (_display_popup_message "Frame complete." "" 0)
  100.             )
  101.         ;else
  102.             (_display_popup_message "No marked block!" "" 1)
  103.         )
  104.     )
  105. )
  106. (macro _control_key
  107.     (
  108.         (if (= dbr_curr_line (inq_mode))
  109.             (insert_mode)
  110.         ;else
  111.             (= dbr_curr_line 0)
  112.         )
  113.         (assign_to_key "<ctrl-f1>" "_ul")
  114.         (assign_to_key "<ctrl-f2>" "_ur")
  115.         (assign_to_key "<ctrl-f3>" "_hr")
  116.         (assign_to_key "<ctrl-f4>" "_vr")
  117.         (assign_to_key "<ctrl-f5>" "_ll")
  118.         (assign_to_key "<ctrl-f6>" "_lr")
  119.     )
  120. )
  121. (macro _cursor
  122.     (
  123.         (int            _overtype
  124.         )
  125.         (if (= dbr_curr_line (inq_mode))
  126.             (insert_mode)
  127.         ;else
  128.             (= dbr_curr_line 0)
  129.         )
  130.         (assign_to_key "<left>" "_left_arrow")
  131.         (assign_to_key "<up>" "_up_arrow")
  132.         (assign_to_key "<down>" "_down_arrow")
  133.         (assign_to_key "<right>" "_right_arrow")
  134.         (= temp_int 0)
  135.         (_display_graphics_mode dbr_graphics)
  136.     )
  137. )
  138. (macro nodr
  139.     (
  140.         (if dbr_curr_line
  141.             (insert_mode)
  142.         )
  143.         (assign_to_key "<ctrl-f1>" "nothing")
  144.         (assign_to_key "<ctrl-f2>" "nothing")
  145.         (assign_to_key "<ctrl-f3>" "nothing")
  146.         (assign_to_key "<ctrl-f4>" "nothing")
  147.         (assign_to_key "<ctrl-f5>" "search_case")
  148.         (assign_to_key "<ctrl-f6>" "toggle_re")
  149.         (assign_to_key "<left>" "left")
  150.         (assign_to_key "<up>" "up")
  151.         (assign_to_key "<down>" "down")
  152.         (assign_to_key "<right>" "right")
  153.         (_display_popup_message "Draw mode is off." "" 0)
  154.     )
  155. )
  156. (macro _left_arrow
  157.     (
  158.         (string            _characters
  159.         )
  160.         (if (!= (read 1) "\n")
  161.             (delete_char)
  162.         )
  163.         (switch temp_int
  164.             1
  165.                 (= _characters ur_char)
  166.             3
  167.                 (= _characters lr_char)
  168.             0    NULL
  169.             2  NULL
  170.             4
  171.                 (= _characters hr_char)
  172.         )
  173.         (insert (substr _characters dbr_graphics 1))
  174.         (move_rel 0 -2)
  175.         (= temp_int 2)
  176.     )
  177. )
  178. (macro _right_arrow
  179.     (
  180.         (string            _characters
  181.         )
  182.         (if (&& (!= (read 1) "\n")(! (inq_mode)))
  183.             (delete_char)
  184.         )
  185.         (switch temp_int
  186.             0    NULL
  187.             2    NULL
  188.             4
  189.                 (= _characters hr_char)
  190.             1
  191.                 (= _characters ul_char)
  192.             3
  193.                 (= _characters ll_char)
  194.         )
  195.         (insert (substr _characters dbr_graphics 1))
  196.         (= temp_int 4)
  197.     )
  198. )
  199. (macro _down_arrow
  200.     (
  201.         (string            _characters
  202.         )
  203.         (if (&& (!= (read 1) "\n")(! (inq_mode)))
  204.             (delete_char)
  205.         )
  206.         (switch temp_int
  207.             0    NULL
  208.             1    NULL
  209.             3
  210.                 (= _characters vr_char)
  211.             2
  212.                 (= _characters ul_char)
  213.             4
  214.                 (= _characters ur_char)
  215.         )
  216.         (insert (substr _characters dbr_graphics 1))
  217.         (move_rel 1 -1)
  218.         (= temp_int 3)
  219.     )
  220. )
  221. (macro _up_arrow
  222.     (
  223.         (string            _characters
  224.         )
  225.         (if (&& (!= (read 1) "\n")(! (inq_mode)))
  226.             (delete_char)
  227.         )
  228.         (switch temp_int
  229.             0    NULL
  230.             1    NULL
  231.             3
  232.                 (= _characters vr_char)
  233.             2
  234.                 (= _characters ll_char)
  235.             4
  236.                 (= _characters lr_char)
  237.         )
  238.         (insert (substr _characters dbr_graphics 1))
  239.         (move_rel -1 -1)
  240.         (= temp_int 1)
  241.     )
  242. )
  243. (macro _ul
  244.     (
  245.         (= temp_int 1)
  246.         (_right_arrow)
  247.     )
  248. )
  249. (macro _ur
  250.     (
  251.         (= temp_int 4)
  252.         (_down_arrow)
  253.         (move_rel -1 1)
  254.     )
  255. )
  256. (macro _hr
  257.     (
  258.         (= temp_int 0)
  259.         (_right_arrow)
  260.     )
  261. )
  262. (macro _vr
  263.     (
  264.         (= temp_int 0)
  265.         (_up_arrow)
  266.         (move_rel 1 1)
  267.     )
  268. )
  269. (macro _lr
  270.     (
  271.         (= temp_int 4)
  272.         (_up_arrow)
  273.         (move_rel 1 1)
  274.     )
  275. )
  276. (macro _ll
  277.     (
  278.         (= temp_int 3)
  279.         (_right_arrow)
  280.     )
  281. )
  282. (macro _line
  283.     (
  284.         (extern        _col_delete
  285.         )
  286.         (int            beg_line
  287.                         beg_col
  288.                         end_line
  289.                         end_col
  290.                         length
  291.                         line_height
  292.                         mark_type
  293.         )
  294.         (string        line
  295.                         vert_char
  296.                         prompt_string
  297.         )
  298.         (= mark_type (inq_marked beg_line beg_col end_line end_col))
  299.         (if (|| (== end_line beg_line)(== mark_type 3))
  300.             (= prompt_string "Horz. Chr's 1)≡  2)≈  3)▀  4)▄  5)─  6)═  7)* ")
  301.         ;else
  302.             (= prompt_string "Vert. Chr's 1)▌  2)▐  3)│  4)║  5)* ")
  303.         )
  304.         (if (== (get_parm 1 temp_str prompt_string 1) 1)
  305.             (
  306.                 (= temp_int (atoi temp_str))
  307.                 (if (&& (> temp_int 0)(< temp_int 8))
  308.                     (
  309.                         (if (== (substr prompt_string 1 4) "Vert")
  310.                             (
  311.                                 (+= temp_int 2)
  312.                                 (= vert_char (substr "≡≈▌▐│║*" temp_int 1))
  313.                                 (= line "")
  314.                             )
  315.                         ;else
  316.                             (= line (substr "≡≈▀▄─═*" temp_int 1))
  317.                         )
  318.                         (if (<= mark_type 3)
  319.                             (
  320.                                 (message "Drawing image, stand by...")
  321.                                 (if (== mark_type 3)
  322.                                     (
  323.                                         (= beg_col 1)
  324.                                         (beginning_of_line)
  325.                                         (delete_to_eol)
  326.                                         (= beg_line end_line)
  327.                                         (= end_col (- (inq_line_length) 1))
  328.                                     )
  329.                                 )
  330.                                 (save_position)
  331.                                 (raise_anchor)
  332.                                 (if (strlen line)
  333.                                     (
  334.                                         (set_msg_level 3)
  335.                                         (move_abs 0 beg_col)
  336.                                         (drop_anchor 2)
  337.                                         (move_abs 0 end_col)
  338.                                         (_col_delete)
  339.                                         (= length (+ (- end_col beg_col) 1))
  340.                                         (move_abs beg_line beg_col)
  341.                                         (= temp_int 0)
  342.                                         (move_abs beg_line beg_col)
  343.                                         (= line (_replicate line length))
  344.                                         (insert line)
  345.                                         (set_msg_level 0)
  346.                                     )
  347.                             ;else
  348.                                     (
  349.                                         (= line_height (- end_line beg_line))
  350.                                         (move_abs beg_line beg_col)
  351.                                         (= temp_int 0)
  352.                                         (while (<= temp_int line_height)
  353.                                             (
  354.                                                 (if (!= (read 1) "\n")
  355.                                                     (delete_char)
  356.                                                 )
  357.                                                 (insert vert_char)
  358.                                                 (move_rel 1 -1)
  359.                                                 (++ temp_int)
  360.                                             )
  361.                                         )
  362.                                     )
  363.                                 )
  364.                                 (restore_position)
  365.                                 (message "")
  366.                                 (_display_popup_message "Drawing complete..." "" 0)
  367.                             )
  368.                         ;else
  369.                             (_display_popup_message "Incorrect mark type!" "" 1)
  370.                         )
  371.                     )
  372.                 ;else
  373.                     (_display_popup_message "Invalid response!" "" 1)
  374.                 )
  375.             )
  376.         )
  377.     )
  378. )
  379. (macro _box
  380.     (
  381.         (int            beg_line
  382.                         beg_col
  383.                         end_line
  384.                         end_col
  385.                         length
  386.         )
  387.         (string        line
  388.                         uprt_char
  389.                         uplt_char
  390.                         lrlt_char
  391.                         lrrt_char
  392.                         vert_char
  393.         )
  394.         (if (== (get_parm 1 temp_str "Box Chr's 1░ 2▒ 3▓ 4█ 5│ 6║ 7* 8<space> " 1) 1)
  395.             (
  396.                 (= temp_int (atoi temp_str))
  397.                 (if (&& (< temp_int 9)(> temp_int 0))
  398.                     (
  399.                         (= line (substr "░▒▓█─═* " temp_int 1))
  400.                         (= uplt_char (substr "░▒▓█┌╔* " temp_int 1))
  401.                         (= uprt_char (substr "░▒▓█┐╗* " temp_int 1))
  402.                         (= lrlt_char (substr "░▒▓█└╚* " temp_int 1))
  403.                         (= lrrt_char (substr "░▒▓█┘╝* " temp_int 1))
  404.                         (= vert_char (substr "░▒▓█│║* " temp_int 1))
  405.                         (if (== 2 (inq_marked beg_line beg_col end_line end_col))
  406.                             (
  407.                                 (message "Drawing image, stand by...")
  408.                                 (save_position)
  409.                                 (raise_anchor)
  410.                                 (= length (- (- end_col beg_col) 1))
  411.                                 (move_abs beg_line beg_col)
  412.                                 (= line (_replicate line length))
  413.                                 (insert uplt_char)
  414.                                 (insert line)
  415.                                 (insert uprt_char)
  416.                                 (drop_anchor 2)
  417.                                 (move_rel 0 (- end_col beg_col))
  418.                                 (set_msg_level 3)
  419.                                 (_col_delete)
  420.                                 (down)
  421.                                 (inq_position temp_int)
  422.                                 (while (< temp_int end_line)
  423.                                     (
  424.                                         (move_abs 0 beg_col)
  425.                                         (if (!= (read 1) "\n")
  426.                                             (delete_char)
  427.                                         )
  428.                                         (insert vert_char)
  429.                                         (move_abs 0 end_col)
  430.                                         (if (!= (read 1) "\n")
  431.                                             (delete_char)
  432.                                         )
  433.                                         (insert vert_char)
  434.                                         (down)
  435.                                         (inq_position temp_int)
  436.                                     )
  437.                                 )
  438.                                 (move_abs 0 beg_col)
  439.                                 (insert lrlt_char)
  440.                                 (insert line)
  441.                                 (insert lrrt_char)
  442.                                 (drop_anchor 2)
  443.                                 (move_rel 0 (- end_col beg_col))
  444.                                 (_col_delete)
  445.                                 (restore_position)
  446.                                 (set_msg_level 0)
  447.                                 (message "")
  448.                                 (_display_popup_message "Drawing complete..." "" 0)
  449.                             )
  450.                         ;else
  451.                             (_display_popup_message "No block marked!" "" 1)
  452.                         )
  453.                     )
  454.                 ;else
  455.                     (_display_popup_message "Invalid response!" "" 1)
  456.                 )
  457.             )
  458.         )
  459.     )
  460. )
  461. (macro _area
  462.     (
  463.         (int            beg_line
  464.                         beg_col
  465.                         end_line
  466.                         end_col
  467.                         length
  468.                         kk
  469.         )
  470.         (string        line
  471.         )
  472.         (if (== (get_parm 1 temp_str "Fill Chr's 1░ 2▒ 3▓ 4█ 5* 6<space> " 1) 1)
  473.             (
  474.                 (= temp_int (atoi temp_str))
  475.                 (if (&& (< temp_int 7)(> temp_int 0))
  476.                     (
  477.                         (= line (substr "░▒▓█* " temp_int 1))
  478.                         (if (== 2 (inq_marked beg_line beg_col end_line end_col))
  479.                             (
  480.                                 (message "Drawing image, stand by...")
  481.                                 (set_msg_level 3)
  482.                                 (save_position)
  483.                                 (_col_delete)
  484.                                 (= length (- end_col beg_col))
  485.                                 (move_abs beg_line beg_col)
  486.                                 (= line (_replicate line (+ length 1)))
  487.                                 (= kk 1)
  488.                                 (while (<= kk (+ (- end_line beg_line) 1))
  489.                                     (
  490.                                         (insert line)
  491.                                         (move_abs 0 beg_col)
  492.                                         (down)
  493.                                         (++ kk)
  494.                                     )
  495.                                 )
  496.                                 (_display_popup_message "Drawing complete..." "" 0)
  497.                                 (set_msg_level 0)
  498.                                 (message "")
  499.                             )
  500.                         ;else
  501.                             (_display_popup_message "Column mark required!" "" 1)
  502.                         )
  503.                     )
  504.                 ;else
  505.                     (_display_popup_message "Invalid response!" "" 1)
  506.                 )
  507.             )
  508.         )
  509.     )
  510. )
  511.