home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 16 / 16.iso / w / w055 / 4.ddi / SOURCES.LIF / BRIEF.PEL < prev    next >
Encoding:
Text File  |  1990-09-27  |  19.0 KB  |  732 lines

  1. # $Header:   P:/source/ppee/macros/brief.pev   1.166   20 Aug 1990 13:47:02   skipr  $
  2.  
  3. ##############################################################################
  4. #
  5. #           Sage Software - POLYTRON Division
  6. #             1700 NW 167th Place
  7. #               Beaverton, OR 97006
  8. #
  9. #   Copyright 1990, Sage Software, Inc.
  10. #
  11. #   Permission is hereby granted for licensed users of Sage Professional
  12. #   Editor and PolyAwk to copy and modify this source code for their own
  13. #   personal use.  These derivative works may be distributed only to other
  14. #   licensed Sage Professional Editor and PolyAwk users.  All other usage
  15. #   is prohibited without express written permission from Sage Software.
  16. #
  17. ##############################################################################
  18.  
  19. #### $Workfile:   brief.pel  $: Key bindings for Brief compatibility
  20.  
  21. local brief_keymap = -1
  22.  
  23. ##
  24. ## BriefKeymap() - define Brief key bindings
  25. ##
  26.  
  27. #    key    #- found in startup keymap
  28. #        #  already defined
  29. #        #    not implemented yet
  30.  
  31. global function brief()                        #PUBLIC #VOID
  32. {
  33.     emulation_mode = "brief";
  34.     execute_event_handler( EVENT_EMULATION_CHANGED );
  35.  
  36.     default_window_flags =                \
  37.         nominal_border_flags =            \
  38.             WINDOW_PLAIN
  39.  
  40.     if ( !and(window_flags, WINDOW_SYSTEM )) {
  41.         window_flags = default_window_flags
  42.     }
  43.  
  44.  
  45.     search_flags =                     \
  46.         + SEARCH_MAXIMAL_MATCH            \
  47.         + SEARCH_FORWARD            \
  48.         + SEARCH_BLOCK                \
  49.         + SEARCH_REGEX                \
  50.     #    + SEARCH_ADVANCE             \
  51.     #    + SEARCH_IGNORE_CASE             \
  52.     #    + SEARCH_WRAPS                \
  53.     #    + SEARCH_HIGHLIGHT            \
  54.  
  55.     toggle_auto_indent( 0 )
  56.  
  57.     if ( !dialog_window ) {
  58.         toggle_dialog( 1 )
  59.     }
  60.  
  61.     message_level = 0
  62.  
  63.  
  64.  
  65.     attach_event_handler( EVENT_NEW_EDIT_FILE, \
  66.         function_id( "new_edit_file" ) );
  67.  
  68.     # Enable the keymap.  Subsequent mods to the keymap will persist
  69.     #    through the end of the session.
  70.     # Only one-time initialization should follow this point.
  71.  
  72.     if( brief_keymap >= 0 ){
  73.         current_keymap = brief_keymap
  74.         return
  75.     }
  76.  
  77.     brief_keymap = current_keymap = create_keymap( factory_keymap )
  78.  
  79.  
  80.     #--------------------------------------------------------------
  81.     # Keypad arrows
  82.     #--------------------------------------------------------------
  83.     assign_key( "<Keypad-8>",        "n_window")
  84.     assign_key( "<Keypad-6>",        "e_window")
  85.     assign_key( "<Keypad-2>",        "s_window")
  86.     assign_key( "<Keypad-4>",        "w_window")
  87.  
  88.     assign_key( "<Alt-Up>",            "n_window")
  89.     assign_key( "<Alt-Right>",        "e_window")
  90.     assign_key( "<Alt-Down>",        "s_window")
  91.     assign_key( "<Alt-Left>",        "w_window")
  92.  
  93.  
  94.     #--------------------------------------------------------------
  95.     # Basic Text commands
  96.     #--------------------------------------------------------------
  97.  
  98.     assign_key( "<Enter>",            "auto_indent_cr" )
  99.     #-assign_key( "<Ctrl-Enter>",        "auto_indent_nl" )
  100.     #-assign_key( "<Alt-D>",        "delete_line" )
  101.     #-assign_key( "<Del>",            "delete_chars" )
  102.     assign_key( "<Alt-K>",            "delete_to_eol" )
  103.     assign_key( "<Tab>",            "indent_tab_maybe" )
  104.     assign_key( "<Shift-Tab>",        "outdent_tab_maybe" )
  105. #    assign_key( "<Space>",            "indent_outdent_space" )
  106.     assign_key( "<Bksp>",            "brief_backspace" )
  107.     assign_key( "<Ctrl-Bksp>",        "brief_backspace" )
  108.  
  109.  
  110.     #--------------------------------------------------------------
  111.     # Macros and keystroke recordings
  112.     #--------------------------------------------------------------
  113.     assign_key( "<Alt-F7>",            "brief_load_key_file" )
  114.     assign_key( "<Alt-F8>",            "brief_write_key_file" )
  115.     assign_key( "<F7>",            "brief_record_macro" )
  116.     assign_key( "<F8>",            "brief_playback_macro" )
  117.     assign_key( "<F9>",            "system_key" )
  118.     assign_key( "<F10>",            "invoke_function" )
  119.     assign_key( "<Shift-F7>",        "brief_pause_recording" )
  120. #    assign_key( "<Shift-F9>",        "" )
  121.  
  122.  
  123.     #--------------------------------------------------------------
  124.     # Manipulating Buffers
  125.     #--------------------------------------------------------------
  126.     assign_key( "<Alt-B>",            "buffer_list" )
  127.     assign_key( "<Alt-E>",            "edit_file_key" )
  128.     assign_key( "<Alt-F>",            "display_filename" )
  129.     assign_key( "<Alt-Minus>",        "prev_buffer_key" )
  130.     assign_key( "<Alt-Keypad-Minus>",    "prev_buffer_key" )
  131.     assign_key( "<Ctrl-Minus>",        "brief_delete_buffer" )
  132.     assign_key( "<Ctrl-Keypad-Minus>",    "brief_delete_buffer" )
  133.     assign_key( "<Alt-R>",            "read_file_key" )
  134.     assign_key( "<Alt-O>",            "change_output_name" )
  135.     assign_key( "<Alt-N>",            "next_buffer_key" )
  136.     assign_key( "<Ctrl-X>",            "write_and_exit" )
  137.  
  138.  
  139.     #--------------------------------------------------------------
  140.     # Windows
  141.     #--------------------------------------------------------------
  142.     assign_key( "<F1>",            "brief_change_window" )
  143.     assign_key( "<F2>",            "adjust_window" )
  144.     assign_key( "<F3>",            "brief_create_window" )
  145.     assign_key( "<F4>",            "brief_delete_window" )
  146.     assign_key( "<Alt-F1>",            "toggle_borders" )
  147.     assign_key( "<Alt-F2>",            "toggle_window_zoom" )
  148.  
  149.  
  150.     #--------------------------------------------------------------
  151.     # Cursor Movement
  152.     #--------------------------------------------------------------
  153.     #-assign_key( "<Down>",            "down" )
  154.     #-assign_key( "<Left>",            "left" )
  155.     #-assign_key( "<Right>",            "right" )
  156.     #-assign_key( "<Up>",            "up" )
  157.     assign_key( "<Ctrl-Left>",        "prev_word" )
  158.     assign_key( "<Alt-Bksp>",        "delete_word" )
  159.     assign_key( "<Ctrl-Bksp>",        "delete_prev_word" )
  160.     assign_key( "<Ctrl-T>",            "scroll_window_top" )
  161.     assign_key( "<Home>",            "home_key" )
  162.     assign_key( "<End>",            "end_key" )
  163.     assign_key( "<Ctrl-Home>",        "goto_window_top" )
  164.     assign_key( "<Ctrl-End>",        "goto_window_bottom" )
  165.     # assign_key( "<Keypad-7>",        "goto_window_left" )
  166.     # assign_key( "<Keypad-1>",        "goto_window_right" )
  167.  
  168.     #-assign_key( "<PgUp>",            "page_up" )
  169.     #-assign_key( "<PgDn>",            "page_down" )
  170.     assign_key( "<Alt-G>",            "goto_line_key" )
  171.     assign_key( "<Ctrl-C>",            "center_cursor" )
  172.     assign_key( "<Ctrl-Right>",        "next_word" )
  173.     assign_key( "<Ctrl-B>",            "scroll_window_bottom")
  174.     assign_key( "<Ctrl-U>",            "scroll_down_1")
  175.     assign_key( "<Ctrl-D>",            "scroll_up_1" )
  176.  
  177.     assign_key( "<Ctrl-PgUp>",        "goto_buffer_top" )
  178.     assign_key( "<Ctrl-PgDn>",        "goto_buffer_bottom" )
  179.  
  180.  
  181.     #--------------------------------------------------------------
  182.     # Marked Blocks
  183.     #--------------------------------------------------------------
  184.     assign_key( "<Alt-M>",            "set_inclusive_mark" )
  185.     assign_key( "<Alt-L>",            "set_line_mark" )
  186.     assign_key( "<Alt-C>",            "set_column_mark" )
  187.     assign_key( "<Alt-A>",            "set_exclusive_mark" )
  188.     assign_key( "<Keypad-+>",        "copy_to_scrap_key" )
  189.  
  190.     assign_key( "<Alt-P>",            "print_buffer" )
  191.     assign_key( "<Alt-W>",            "write_block_key" )
  192.     #-assign_key( "<Ins>",            "insert_scrap" )
  193.     assign_key( "<Keypad-Minus>",        "brief_delete_to_scrap")
  194.  
  195.  
  196.     #--------------------------------------------------------------
  197.     # Miscellaneous
  198.     #--------------------------------------------------------------
  199.  
  200.     assign_key( "<Alt-1>",            "place_bookmark 1")
  201.     assign_key( "<Alt-2>",            "place_bookmark 2")
  202.     assign_key( "<Alt-3>",            "place_bookmark 3")
  203.     assign_key( "<Alt-4>",            "place_bookmark 4")
  204.     assign_key( "<Alt-5>",            "place_bookmark 5")
  205.     assign_key( "<Alt-6>",            "place_bookmark 6")
  206.     assign_key( "<Alt-7>",            "place_bookmark 7")
  207.     assign_key( "<Alt-8>",            "place_bookmark 8")
  208.     assign_key( "<Alt-9>",            "place_bookmark 9")
  209.     assign_key( "<Alt-0>",            "place_bookmark 10")
  210.     assign_key( "<Alt-J>",            "goto_bookmark")
  211.  
  212.     assign_key( "<Ctrl-A>",            "optional_function display_ascii_table" )
  213.     assign_key( "<Ctrl-G>",            "optional_function routines" )
  214.     assign_key( "<Alt-X>",            "done" )
  215.     assign_key( "<Alt-I>",            "toggle_insert_mode" )
  216.     assign_key( "<Ctrl-N>",            "goto_next_error" )
  217.     assign_key( "<Ctrl-W>",            "toggle_file_backup" )
  218.     assign_key( "<Keypad-*>",        "undo" )
  219.     #-assign_key( "<Alt-U>",        "undo" )
  220.     assign_key( "<Alt-Y>",            "redo" )
  221.  
  222.     assign_key( "<Alt-H>",            "help")
  223.     assign_key( "<Alt-Z>",            "system" )
  224.     assign_key( "<Alt-V>",            "print_version" )
  225.     assign_key( "<Ctrl-P>",            "display_errors" )
  226.  
  227.     assign_key( "<Alt-Q>",            "insert_quoted_key" )
  228.     assign_key( "<Alt-F10>",        "compile_buffer" )
  229.     assign_key( "<Ctrl-R>",            "repeat_key_action" )
  230.     assign_key( "<Shift-F10>",        "insert_keys" )
  231.     assign_key( "#27",    "expand_template" )    # Ctrl-[ or Esc
  232.  
  233.  
  234.     #--------------------------------------------------------------
  235.     # Searching and translating
  236.     #--------------------------------------------------------------
  237.     assign_key( "<Alt-S>",            "search_forward" )
  238.     assign_key( "<F5>",            "search_forward" )
  239.     assign_key( "<Alt-T>",            "replace_forward" )
  240.     assign_key( "<F6>",            "replace_forward" )
  241.     assign_key( "<Alt-F5>",            "search_backward" )
  242.     assign_key( "<Shift-F5>",        "search_again" )
  243.     assign_key( "<Ctrl-F5>",        "toggle_search_case" )
  244.     assign_key( "<Alt-F6>",            "replace_backward" )
  245.     assign_key( "<Shift-F6>",        "replace_again" )
  246.     assign_key( "<Ctrl-F6>",        "toggle_search_regex" )
  247.  
  248.  
  249.     #--------------------------------------------------------------
  250.     # Mouse button codes
  251.     #--------------------------------------------------------------
  252.  
  253.     assign_mouse_buttons()
  254. }
  255.  
  256.  
  257. #---------------------------------------------------------------#
  258. #                                #
  259. #    Functions required to support the brief calls        #
  260. #                                #
  261. #---------------------------------------------------------------#
  262.  
  263. #------------- Basic text commands support ---------------------------------#
  264.  
  265. function brief_backspace(){
  266.     if ((current_column > 1) || (and(buffer_flags, BUFFER_WP_ENABLED))) {
  267.         backspace()
  268.     }
  269. }
  270.  
  271. #------------- Playback/record and Macros functions unique to brief --------#
  272.  
  273.  
  274. global function brief_delete_to_scrap() {
  275.     local    status
  276.  
  277.     if (!region_type())
  278.         drop_anchor( LINE_SELECTION )
  279.  
  280.     status = copy_to_scrap()
  281.     delete_chars()
  282.     raise_anchor()
  283.     return status
  284. }
  285.  
  286.  
  287. #------------- Miscellaneous functions unique to brief ---------------------#
  288.  
  289.  
  290. function brief_delete_buffer(){
  291.     delete_buffer_key("", 1);
  292. }
  293.  
  294. #------------- Window functions unique to brief ---------------------#
  295.  
  296. local NORTH = 0x1
  297. local EAST  = 0x2
  298. local SOUTH = 0x4
  299. local WEST  = 0x8
  300.  
  301. local function get_window_direction( msg ) {
  302.     local    ch
  303.  
  304.  
  305.     while (TRUE) {
  306.         if (msg) {
  307.             begin_dialog()
  308.             notify( msg "(use arrow keys)." )
  309.             ch = getchar()
  310.             end_dialog()
  311.         } else {
  312.             ch = getchar()
  313.         }
  314.         if (ch == 0) {
  315.             ch = getchar()
  316.             if (ch == SCANCODE_UP)        return NORTH
  317.             else if (ch == SCANCODE_DOWN)    return SOUTH
  318.             else if (ch == SCANCODE_LEFT)    return WEST
  319.             else if (ch == SCANCODE_RIGHT)    return EAST
  320.         }
  321.         return 0
  322.     }
  323. }
  324.  
  325.  
  326.  
  327. local function adjacent_window( direction ) {
  328.     local    x = window_text_x0 + distance_to_window_left()
  329.     local    y = window_text_y0 + distance_to_window_top()
  330.     local    NULL = 0
  331.     local    margin
  332.     local    i
  333.     local    win
  334.     local    savewin = current_window
  335.     local    wflags
  336.  
  337.     if (direction == NORTH) {
  338.         margin = 0
  339.     } else if (direction == EAST) {
  340.         margin = display_width
  341.     } else if (direction == SOUTH) {
  342.         margin = display_height
  343.     } else if (direction == WEST) {
  344.         margin = 0
  345.     } else {
  346.         return NULL
  347.     }
  348.  
  349.     if ( and(direction, SOUTH+NORTH) ) {
  350.         direction = (margin == 0) ? -1 : 1
  351.         for ( ; y != margin; y += direction) {
  352.             win = window_containing( x, y )
  353.             if ((win != NULL) && (win != current_window) ) {
  354.                 current_window = win
  355.                 wflags = window_flags
  356.                 if (savewin)
  357.                     current_window = savewin
  358.                 if (!(and(wflags,WINDOW_SYSTEM)) )
  359.                     return win
  360.             }
  361.         }
  362.     } else {
  363.         direction = (margin == 0) ? -1 : 1
  364.         for ( ; x != margin; x += direction) {
  365.             win = window_containing( x, y )
  366.             if ((win != NULL) && (win != current_window)) {
  367.                 current_window = win
  368.                 wflags = window_flags
  369.                 if (savewin)
  370.                     current_window = savewin
  371.                 if (!(and(wflags,WINDOW_SYSTEM)) )
  372.                     return win
  373.             }
  374.         }
  375.     }
  376.     return NULL
  377. }
  378.  
  379.  
  380. global function n_window() {
  381.     return move_to_adjacent_window( NORTH )
  382. }
  383. global function s_window() {
  384.     return move_to_adjacent_window( SOUTH )
  385. }
  386. global function w_window() {
  387.     return move_to_adjacent_window( WEST )
  388. }
  389. global function e_window() {
  390.     return move_to_adjacent_window( EAST )
  391. }
  392.  
  393. local function move_to_adjacent_window( direction ) {
  394.     local win = adjacent_window( direction )
  395.  
  396.     if ( win ) {
  397.         current_window = win
  398.         display_filename()
  399.         return TRUE
  400.     } else {
  401.         notify("No window found.")
  402.         return FALSE
  403.     }
  404. }
  405.  
  406.  
  407. ## brief-style window change
  408. #
  409. function brief_change_window( direction ) {
  410.     local    status = FALSE
  411.  
  412.     if (!argcount())
  413.         direction = get_window_direction( "Select new current window " )
  414.  
  415.     if ( direction == NORTH )    status = n_window()
  416.     else if (direction == SOUTH) status = s_window()
  417.     else if (direction == WEST)  status = w_window()
  418.     else if (direction == EAST)  status = e_window()
  419.     else message( "" )
  420.     return status
  421. }
  422.  
  423. ## brief-style window resize (or as close to it as need be)
  424. #
  425. function brief_resize_window( ironside, amount ) {
  426.     local    direction
  427.     local    x0 = window_x0
  428.     local    y0 = window_y0
  429.     local    xExt = window_width
  430.     local    yExt = window_height
  431.     local    useAmount
  432.  
  433.     if (!argcount()) {
  434.         ironside = get_window_direction( "Select side to move " )
  435.         amount = 0;
  436.     } else if ( (useAmount = (argcount() == 2)) ) {
  437.         if (!amount)
  438.             return;
  439.     }
  440.  
  441.     if (ironside) {
  442.         direction = (useAmount)        \
  443.             ? ironside        \
  444.             : get_window_direction( "Move window edge " )
  445.  
  446.         while (direction)  {
  447.             if (ironside == NORTH) {
  448.                 if (direction == NORTH) {
  449.                     if (y0 > 0)
  450.                         { y0--; yExt++; }
  451.                 } else if (direction == SOUTH) {
  452.                     if (yExt > 1)
  453.                         { y0++; yExt--; }
  454.                 }
  455.             } else if (ironside == SOUTH) {
  456.                 if (direction == NORTH) {
  457.                     if (yExt > 1)
  458.                         yExt--
  459.                 } else if (direction == SOUTH) {
  460.                     if (yExt+y0 < display_height)
  461.                         yExt++
  462.                 }
  463.             } else if (ironside == WEST) {
  464.                 if (direction == WEST)  {
  465.                     if (x0 > 0)
  466.                         { x0--; xExt++; }
  467.                 } else if (direction == EAST) {
  468.                     if (xExt > 1)
  469.                         { x0++; xExt--; }
  470.                 }
  471.             } else if (ironside == EAST) {
  472.                 if (direction == WEST) {
  473.                     if (xExt > 1)
  474.                         xExt--
  475.                 } else if (direction == EAST) {
  476.                     if (xExt+x0 < display_width)
  477.                         xExt++
  478.                 }
  479.             }
  480.  
  481.             if (useAmount) {
  482.                 amount--;
  483.             }
  484.  
  485.             if (amount == 0) {
  486.                 frame_window( x0, y0, xExt, yExt )
  487.                 display_update()
  488.                 if (useAmount)        # are we done yet
  489.                     break;
  490.                 direction = get_window_direction( "" )
  491.             }
  492.         }
  493.     }
  494.     message( "" )
  495. }
  496.  
  497.  
  498. ## brief-style window creation
  499. #
  500. function brief_create_window( direction )
  501. {
  502.     local    ch
  503.  
  504.     if (!argcount()) {
  505.         direction = get_window_direction( "Select side for new window ")
  506.         message( "" )
  507.     }
  508.  
  509.     if (direction) {
  510.         if (and( direction, NORTH+SOUTH) ) {
  511.             if (split_window_horizontal()) {
  512.                 if ( direction == NORTH )
  513.                     prev_window()
  514.                 return TRUE
  515.             }
  516.         } else { #direction = EAST or WEST
  517.             if (split_window_vertical()) {
  518.                 if (direction == WEST)
  519.                     prev_window()
  520.                 return TRUE
  521.             }
  522.         }
  523.     }
  524.     return FALSE
  525. }
  526.  
  527. ## brief-style window delete
  528. #
  529.  
  530. function brief_delete_window( direction ){
  531.     local    w = current_window
  532.     local    ch
  533.  
  534.     if ( next_window() == w ) {
  535.         warning( "Cannot delete last window" )
  536.         return
  537.     } else {
  538.         if (w)
  539.             current_window = w
  540.     }
  541.  
  542.     if (!argcount()) {
  543.         direction = get_window_direction( "Select edge to delete ")
  544.         message( "" )
  545.     }
  546.  
  547.     if (direction) {
  548.         delete_window_edge( direction )
  549.     } else if (current_key == 0x3E)        # F4 - we used getchar(), remember
  550.         delete_tiled_window()
  551. }
  552.  
  553. ## delete a window's edge given the direction of the edge
  554. #    the edge is not deleted unless an adjoining window can be found
  555.  
  556. local function delete_window_edge( dir ){
  557.     local x0 = window_x0
  558.     local y0 = window_y0
  559.     local x1 = x0 + window_width - 1
  560.     local y1 = y0 + window_height - 1
  561.     local cw = current_window;
  562.     local cur;
  563.  
  564.     if (and(window_flags,WINDOW_SYSTEM))
  565.         cur = next_window();
  566.     else
  567.         cur = cw;
  568.  
  569.     do {
  570.         if( current_window != cur        \
  571.         &&  delete_adjacent_edge( dir, cur, x0, y0, x1, y1 )){
  572.             delete_window_key()
  573.             if (cw)
  574.                 current_window = cw
  575.             return
  576.         }
  577.         next_window()
  578.     } while( cur != current_window )
  579.     if (cw)
  580.         current_window = cw;
  581.  
  582.     warning( "Edge does not have exactly two adjoining windows" )
  583. }
  584.  
  585. local function delete_adjacent_edge( dir, cur, x0, y0, x1, y1 ){
  586.     local cx0 = window_x0
  587.     local cy0 = window_y0
  588.     local cx1 = cx0 + window_width - 1
  589.     local cy1 = cy0 + window_height - 1
  590.  
  591.     if( x0 == cx0 && x1 == cx1 ){
  592.         if( dir == NORTH && cy1 + 1 == y0  ){        # above
  593.             frame_window( x0, cy0, window_width, y1 - cy0 + 1, cur )
  594.             return 1
  595.         } else if( dir == SOUTH && y1 + 1 == cy0 ){    # below
  596.             frame_window( x0, y0, window_width, cy1 - y0 + 1, cur )
  597.             return 1
  598.         }
  599.     } else if( y0 == cy0 && y1 == cy1 ){
  600.         if( dir == WEST && cx1 + 1 == x0 ){        # left
  601.             frame_window( cx0, cy0, x1 - cx0 + 1, window_height, cur )
  602.             return 1
  603.         } else if( dir == EAST && x1 + 1 == cx0 ){    # right
  604.             frame_window( x0, y0, cx1 - x0 + 1, window_height, cur )
  605.             return 1
  606.         }
  607.     }
  608.  
  609.     return 0
  610. }
  611.  
  612.  
  613. #
  614. # new_edit_file()
  615. #
  616. # Whenever a new edit file is created, the extension is stripped from
  617. # the file name and a function with that extension (preceded by "_")
  618. # is invoked. If the function does not exist, "default()" is called.
  619. #
  620. global function new_edit_file() {
  621.     local    ext = path_ext( buffer_filename );
  622.     local    lev = message_level;
  623.     local    def_name = "default"
  624.     local    id
  625.  
  626.     message_level = 3;
  627.  
  628.     if (ext) {
  629.         if (substr( ext, 1, 1 ) == "." ) {
  630.             ext = "_" substr( ext, 2 );
  631.             id = function_id( ext );
  632.             if ( id ) {
  633.                 message_level = lev;
  634.                 execute_function( ext );
  635.                 return;
  636.             }
  637.         }
  638.     }
  639.  
  640.     id = function_id( def_name );
  641.     message_level = lev;
  642.     if ( id )
  643.         execute_function( def_name );
  644.  
  645. }
  646.  
  647.  
  648.  
  649. global    currentRecordString = "";
  650. local    pausedRecordString  = "";
  651. local    recordingPaused = 0;
  652.  
  653. function brief_pause_recording(){
  654.     if (!recording && recordingPaused) {
  655.         record();
  656.         recordingPaused = 0;
  657.         recording = 1;
  658.     } else if (recording == 1) {
  659.         pausedRecordString = pausedRecordString record();
  660.         recordingPaused = 1;
  661.         recording = 0;
  662.     }
  663. }
  664.  
  665.  
  666. function brief_record_macro(){
  667.     local    str;
  668.  
  669.     if (playingback)
  670.         return;
  671.  
  672.     if (recordingPaused ) {
  673.         message( "Keystroke macro defined." );
  674.         recordingPaused = 0;
  675.         str = ""
  676.     } else {
  677.         str = record_key();
  678.     }
  679.  
  680.     currentRecordString = pausedRecordString str;
  681.     pausedRecordString = ""
  682. }
  683.  
  684. function brief_playback_macro(){
  685.     if (recordingPaused ) {
  686.         message( "Playback while recording." );
  687.     } else {
  688.         if (currentRecordString)
  689.             playback_macro( currentRecordString );
  690.         else
  691.             playback_macro();
  692.     }
  693. }
  694.  
  695. function brief_load_key_file(){
  696.     local    str = prompt_history( "RECORD", "Keystroke macro file: ", "",1 );
  697.     local    fid;
  698.     local    ch;
  699.  
  700.     if (str) {
  701.         if ((fid = fopen( str, 0 )) > 0) {
  702.             while ((ch = fgetc(fid)) >= 0) {
  703.                 currentRecordString = currentRecordString chr(ch);
  704.             }
  705.             fclose( fid );
  706.         } else {
  707.             notify( "Unable to open: " str );
  708.         }
  709.     }
  710. }
  711.  
  712. function brief_write_key_file(){
  713.     local    str;
  714.     local    fid;
  715.  
  716.     if (currentRecordString) {
  717.         str = prompt_history( "RECORD", "Save keystrokes as: ", "", 1 );
  718.         if (str) {
  719.             if ((fid = fopen( str, 1 )) > 0) {
  720.                 fprintf( fid, currentRecordString );
  721.                 fclose( fid );
  722.             } else {
  723.                 notify( "Unable to open: " str );
  724.             }
  725.         }
  726.     } else {
  727.         notify( "No keystroke macro to save." );
  728.     }
  729. }
  730.  
  731.  
  732.