;************************************************************************
;**                  for   B R I E F   ver. 2.1                         *
;**                                                                     *
;**        Clrsel changes the current buffer to the selected color.     *
;**                                                                     *
;**         By Tom Bentley     November 1988     Ver. 1.1               *
;**                                                                     *
;**                 (C) Copyright - All rights reserved                 *
;**                                                                     *
;************************************************************************

#include "dialog.h"

(extern    clr_buf_mnu clr_buf_ids clr_button_line clr_button_text clr_flag)

(macro clrsel
   (
      (int     curr_buff)
      (string  buf_strg)

      (= curr_buff (inq_buffer))
      (= clr_flag 0)
      (_process_menu 28 19 53 3 "Color_Menu" "Select a Color"
          NULL clr_buf_mnu "select_clr_event")
      (if (== clr_flag 1)
         (
            (set_buffer clr_buf_ids)
            (goto_line 1)
            (sprintf buf_strg "<%d" curr_buff)
            (if (search_fwd buf_strg)
               (
                  (delete_line)
               )
            )
            (if (!= clr_button_line 1)
               (
                  (goto_line 1)
                  (execute_macro "open_line")
                  (sprintf buf_strg "%d" curr_buff)
                  (insert buf_strg)
                  (insert (substr clr_button_text
                     (index clr_button_text ";")))
               )
            )
         )
      )
      (set_buffer curr_buff)
   )
)

(macro select_clr_event
   (
      (int      key)
      (string  text)

      (get_parm 0 key)
      (if (== key DIALOG_PICK_MENU)
         (
            (get_parm 1 clr_button_line)
            (get_parm 2 clr_button_text)
            (= text (compress clr_button_text))
            (= clr_flag 1)
            (push_back (key_to_int "<esc>"))
         )
      )
      (returns TRUE)
   )
)

