home *** CD-ROM | disk | FTP | other *** search
- $MACRO_FILE KEYMAC;
- $MACRO KEYMAC_LIST;
- {
- @DISPLAY_STRING=D=26K=16
- /TP=9/C=1/L=1/W=15/H=KM/T=Keystroke assignment:/DBF=K
- /C=1/L=2/W=25/H=KM/T=Description: /DBF=D
- /TP=3/C=1/L=3/W=9/H=KM/T=Mode: /DBF=M/ISTR=EDIT(KM)DOS_SHELL()TERM()ALL()
- /TP=8/C=0/L=4/W=0/H=KM/T=/DBF=S/GSET=1/GSTR=@KM!/ISTR=Edit keystrokes/M=KEYMAC^KEYMAC_EDIT
- ****START****
- }
- Def_Str(K_Str[2048]);
- Def_Int(T_Mode,K1,K2);
-
- {Unload all keys first}
- RM('KEYMAC_LOAD /LM=2/KW=1');
- {Bring up editing menu}
- Create_Global_Str('@KMEV1','/T=Playback keystrokes/K1=13/K2=28/R=1/LL=1');
- RM('USERIN^DB /F=KEYMAC.DB/NOALPHA=1/PRE=KM/GLO=@KMG#/LO=3/H=KM/EV1=@KMEV1/S=' +
- Parse_Str('/S=',MParm_Str) +
- '/LT=KEYSTROKE MACRO MANAGER/DT=EDITING KEYSTROKE MACRO/MACRO=KEYMAC_CHECK');
-
- Set_Global_Str('@KMEV1','');
- T_Mode := Return_Int;
- {Load new list}
- RM('KEYMAC_LOAD');
- IF (T_Mode = 1) THEN
- {Run keystroke macro from menu by temporarily assigning it to a non existant
- keystroke, invoking the keystroke, then unassigning it.}
- K_Str := Global_Str('@KMG#');
- T_Mode := Parse_int('M=',K_Str) - 1;
- IF (T_Mode < 0) THEN
- T_Mode := 0;
- END;
- IF (T_Mode = mode) THEN
- {Don't do it unless we are in the same mode}
- set_global_str('@KMTEMP!#',Reconvert_String(Parse_str('S=',K_Str)));
- global_to_key($FFFF,'@KMTEMP!#',T_Mode);
- Pass_Key($FF,$FF);
- END;
- END;
-
- END_MACRO;
-
- $MACRO KEYMAC_EDIT;
- Def_Str(Key_Buf[2048],T_Return_Str);
- Def_Int(Index,Active_Window,Menu_Window,K1,K2,Col,Row,Result,Choice,Old_Row,
- T_Insert_Mode,TBc,T_Refresh,T_Truncate_Spaces);
-
- Active_Window := Window_Id;
- T_Truncate_Spaces := Truncate_Spaces;
- T_Return_Str := Return_Str;
- T_Refresh := Refresh;
- Refresh := False;
- T_Insert_Mode := Insert_Mode;
- TBC := Box_Count;
- Choice := 1;
- Old_Row := 1;
- Row := Parse_Int('/Y=',MParm_Str);
- IF (Row < 4) THEN
- Row := 4;
- END;
- Col := Parse_Int('/X=',MParm_Str);
- IF (Col < 1) THEN
- Col := 1;
- END;
- Key_Buf := reconvert_string(Global_Str('@KM!'));
- Create_Window;
- Menu_Window := Window_Id;
- File_Name := Fexpand('KEYMAC.TMP');
- Index := 0;
- WHILE (Index < Svl(Key_Buf)) DO
- ++Index;
- K1 := Ascii(Str_Char(Key_Buf,Index));
- ++Index;
- K2 := Ascii(Str_Char(Key_Buf,Index));
- RM('SETUP^MAKEKEY /K1=' + Str(K1) + '/K2=' + Str(K2));
- Put_Line(Return_Str);
- Down;
- END;
- File_Changed := False;
-
- KEY_MENU:
- Create_Global_Str('@KMEV1', '/T=Accept/K1=13/K2=28/R=1/LL=1');
- Create_Global_Str('@KMEV2', '/T=Cancel/K1=27/K2=1/R=0/LL=1');
- Create_Global_Str('@KMEV3', '/T=Add/K1=0/K2=82/R=2');
- Create_Global_Str('@KMEV4', '/T=Delete/K1=0/K2=83/R=3');
- Create_Global_Str('@KMEV5', '/T=Change/K1=0/K2=61/R=4');
-
- RM('USERIN^WMENU /OEM=1/NK=1/SP=%<*/EV=@KMEV/EV#=5/T=EDIT KEYSTROKES/H=EDITKS/X=' +
- Str(Col) + '/Y=' + Str(Row) + '/S=' + Str(Choice) + '/OR=' + Str(Old_Row));
-
- Choice := C_Line;
- Old_Row := C_Row;
- Result := Return_Int;
-
- IF (Result = 0) THEN
- {Abort edit}
- IF (Global_Str('@KM!') <> convert_string(Key_Buf)) THEN
- RM('USERIN^VERIFY /T=Abort the changes?/C=' + Str(Col + 2) + '/L=' + Str(Row + 2));
- IF (Return_Int) THEN
- Goto EXIT;
- END;
- Kill_Box;
- Goto KEY_MENU;
- ELSE
- Goto EXIT;
- END;
- END;
- IF (Result = 1) THEN
- {Exit and save}
- Set_Global_Str('@KM!',convert_string(Key_Buf));
- Goto EXIT;
- END;
- IF (Result = 2) THEN
- {Add a keystroke}
- RM('KEYMAC^KEYMAC_K_PROMPT /T=ADDING A KEYSTROKE/X=' + Str(Col) +
- '/Y=' + Str(Row + Choice));
- IF (Get_Line <> '') THEN
- Insert_Mode := True;
- Eol;
- Cr;
- END;
- Truncate_Spaces := False;
- Put_Line(Return_Str);
- Choice := C_Line;
- Key_Buf := Str_Ins(Char(Key1) + Char(Key2),Key_Buf,(C_Line * 2) - 1);
- Kill_Box;
- Goto KEY_MENU;
- END;
- IF (Result = 3) THEN
- {Delete a keystroke}
- Key_Buf := Str_Del(Key_Buf,(C_Line * 2) - 1,2);
- Del_Line;
- IF (At_Eof) THEN
- --Choice;
- END;
- Kill_Box;
- Goto KEY_MENU;
- END;
- IF (Result = 4) THEN
- {change a keystroke}
- Key_Buf := Str_Del(Key_Buf,(C_Line * 2) - 1,2);
- RM('KEYMAC^KEYMAC_K_PROMPT /T=CHANGING A KEYSTROKE/X=' + Str(Col) +
- '/Y=' + Str(Row + Old_Row + 1));
- Truncate_Spaces := False;
- Put_Line(Return_Str);
- Key_Buf := Str_Ins(Char(Key1) + Char(Key2),Key_Buf,(C_Line * 2) - 1);
- Kill_Box;
- Goto KEY_MENU;
- END;
-
- EXIT:
- WHILE (Box_Count > TBC) DO
- Kill_Box;
- END;
- IF (Switch_Win_Id(Menu_Window)) THEN
- Delete_Window;
- END;
- IF (Switch_Win_Id(Active_Window)) THEN
- END;
- Insert_Mode := T_Insert_Mode;
- Return_Str := T_Return_Str;
- Refresh := T_Refresh;
- END_MACRO;
-
- $MACRO KEYMAC_CHECK;
- Def_int(T_Refresh,k_int,M_Int,K_line,T_Reg_Exp_stat,K_Type,Choice);
- Def_Str(K_Str[30],E_Str[20],M_Str[15],T_Rec[2048]);
-
- IF (Parse_Int('/P=',Mparm_str)) THEN
- T_Refresh := Refresh;
- Refresh := False;
-
- IF (Parse_Str('D=',Global_Str('@KMG#')) = '') THEN
- {Don't allow a blank description, put a default one in}
- T_Rec := Global_Str('@KMG#');
- Set_Global_Str('@KMG#','K=' + Parse_Str('K=',T_Rec) +
- 'D=(unnamed)M=' + Parse_Str('M=',T_Rec) +
- 'S=' + Parse_Str('S=',T_Rec));
- END;
-
- RECHECK:
- Choice := 0;
- T_Rec := Global_Str('@KMG#');
- K_int := Parse_int('K=',T_Rec);
- M_int := Parse_int('M=',T_Rec) - 1;
- IF (M_Int < 0) THEN
- M_Int := 0;
- END;
- IF (K_int > 0) THEN
-
- {First, search for a conflict in the list}
- T_Reg_Exp_Stat := Reg_exp_stat;
- Mark_Pos;
- K_Line := C_Line;
- Tof;
- Reg_exp_stat := true;
-
- Search_AGAIN:
- IF (Search_Fwd('K=' + Str(K_Int) + '||$',0)) THEN
- IF (C_Line = K_Line) THEN
- Eol;
- Goto SEARCH_AGAIN;
- END;
- K_Type := -1;
- Goto KEYSTROKE_CONFLICT;
- END;
- {Next, check for a conflict in memory}
- K_Type := Inq_Key(K_Int and $FF,(K_Int shr 8) and $FF,M_Int,K_Str);
- IF (K_Type) THEN
- M_Str := 'Ignore(KM)';
- IF (K_Type = 1) THEN
- E_Str := 'macro.';
- ELSIF (K_Type = 2) THEN
- KEYSTROKE_CONFLICT:
- E_Str := 'keystroke macro.';
- M_Str := 'Replace(KM)';
- ELSE
- E_Str := 'command.';
- END;
- RM('SETUP^MAKEKEY /K1=' + Str(K_Int and $FF) + '/K2=' +
- Str((K_Int shr 8) and $FF));
- RM('MEERROR^Beeps /C=1');
- Put_Box(15,5,55,10,0,M_B_Color,'WARNING',True);
- Write('The QuickStroke: ' + Return_Str + ' is already',17,6,0,M_B_Color);
- Write('assigned to a ' + E_Str,17,7,0,M_B_Color);
- RM('USERIN^XMENU /T=0/X=17/Y=8/S=1/M=Assign different key(KM)Cancel()'
- + M_Str);
- Choice := Return_Int;
- IF (Choice = 1) THEN
- RM('KEYMAC^KEYMAC_K_PROMPT /T=ENTER A NEW QuickStroke/X=20/Y=7');
- Set_Global_Str('@KMG#','D=' + Parse_Str('D=',T_Rec) +
- 'K=' + Str(Return_Int)+
- 'M=' + Str(M_Int) + 'S=' + Parse_Str('S=',T_Rec));
-
- ELSIF (Choice = 3) THEN
- IF (K_Type = -1) THEN
- Put_Line('D=' + Parse_Str('D=',Get_Line) +
- 'M=' + Parse_Str('M=',Get_Line) +
- 'S=' + Parse_Str('S=',Get_Line));
- Set_Global_Int('@DB_NEED_REBUILD!',1);
- END;
- ELSE
- Set_Global_Str('@KMG#','D=' + Parse_Str('D=',T_Rec) +
- 'M=' + Str(M_Int) + 'S=' + Parse_Str('S=',T_Rec));
- END;
- Kill_Box;
- END;
-
- Goto_Mark;
- Reg_Exp_Stat := T_Reg_exp_stat;
-
- IF (Choice = 1) THEN
- Goto RECHECK;
- END;
-
- END;
-
- Refresh := T_Refresh;
- END;
-
- END_MACRO;
-
- $MACRO KEYMAC_LOAD;
- Def_Int(Active_Window,Keymac_Window,Window_Created,Keymac_Count,
- T_Reg_Exp_Stat,T_Mode,T_Refresh,Load_Mode,K_int,Keep_Window);
-
- T_Reg_Exp_Stat := Reg_Exp_Stat;
- T_Refresh := Refresh;
- Refresh := False;
- Load_Mode := Parse_Int('/LM=',MParm_Str);
- Keep_Window := Parse_Int('/KW=',MParm_Str);
- Keymac_Count := 0;
- Reg_Exp_Stat := false;
- Active_Window := Window_Id;
- Return_Str := 'KEYMAC.DB';
- RM('MAKEUSERPATH /DF=1');
- IF (Switch_File(Return_Str) = 0) THEN
- Window_Created := True;
- Create_Window;
- Load_File(Return_Str);
- IF (Error_Level) THEN
- IF (Parse_Int('/NE=',MParm_Str)) THEN
- Error_Level := 0;
- Goto EXIT;
- END;
- IF (Load_Mode = 1) THEN
- RM('MEERROR /EM=Can''t find ' + Return_Str + ' to save this keystroke macro in.');
- ELSIF (Load_mode = 2) THEN
- RM('MEERROR /EM=Can''t find ' + Return_Str + ' to erase keystroke macros.');
- ELSE
- RM('MEERROR /EM=Can''t find ' + Return_Str + ' to load keystroke macros.');
- END;
- Goto EXIT;
- END;
- END;
-
- IF (Load_Mode = 1) THEN
- Eof;
- IF (C_Col > 1) THEN
- Down;
- END;
- Put_Line('D=' + Parse_Str('/D=',MParm_Str) + 'K=' +
- Parse_Str('/K=',MParm_Str) + 'M=' + Parse_Str('/M=',MParm_Str) +
- 'S=' + Convert_String(Get_Record_Buffer));
- Save_File;
- IF (Error_Level) THEN
- RM('MEERROR /EM=Error saving ' + Return_Str + ' to disk.');
- END;
- Return_Int := C_Line - 6;
- ELSE
- {Find each keystroke macro record and set up the global and key assignment}
- Tof;
- IF (Search_Fwd('****START****',0)) THEN
- Down;
- WHILE (Not(At_Eof)) DO
- IF (Get_Line <> '') THEN
- T_Mode := Parse_Int('M=',Get_Line) - 1;
- IF ((T_Mode <> 0) and (T_Mode <> 1) and (T_Mode <> 3)) THEN
- {Make sure the ME mode is a legal value}
- T_Mode := 0;
- END;
- K_Int := Parse_Int('K=',Get_Line);
- IF (K_Int) THEN
- {Only load those macros who have a key assigned to them}
- ++keymac_count;
- IF (Load_Mode = 2) THEN
- {This will unload the macros from memory}
- set_global_str('@KM!#' + str(keymac_count),'');
- Unassign_key(k_int,t_mode);
- ELSE
- set_global_str('@KM!#' + str(keymac_count),Reconvert_String(Parse_str('S=',Get_Line)));
- global_to_key(K_Int, '@KM!#' + str(keymac_count),T_Mode);
- END;
- END;
- END;
- Down;
- END;
- END;
- IF (Load_Mode = 2) THEN
- set_global_int('@KEYMACRO_COUNT@',0);
- ELSE
- set_global_int('@KEYMACRO_COUNT@', keymac_count );
- END;
- END;
-
- EXIT:
- {
- Refresh := True;
- Window_Attr := 0;
- Eof;
- Redraw;
- Read_Key;
- }
- IF (Window_Created) THEN
- IF (Keep_Window) THEN
- Window_Attr := $81;
- ELSE
- Delete_Window;
- END;
- END;
- IF (Switch_Win_id(Active_Window)) THEN
- END;
- Reg_Exp_Stat := T_Reg_Exp_Stat;
- Refresh := T_Refresh;
- END_MACRO;
-
- $MACRO KEYMAC_K_PROMPT;
- Def_Int(Col,Row,Width);
- Def_Str(Title[80]);
-
- Row := Parse_Int('/Y=',MParm_Str) + 3;
- IF (Row < 4) THEN
- Row := 4;
- END;
- IF (Row > (Max_Window_Row - 4)) THEN
- Row := 4;
- END;
- Col := Parse_Int('/X=',MParm_Str) + 1;
- IF (Col < 1) THEN
- Col := 1;
- END;
- Title := Parse_Str('/T=',MParm_Str);
- Width := 25;
- IF ((Svl(Title) + 3) > Width) THEN
- Width := Svl(Title) + 3;
- END;
-
- Put_Box(Col,Row,Col + Width,Row + 3,0,M_B_Color,Title,true);
- Write('Press the desired key.',(Col + 1) + (((Width - 3) - 22) / 2),Row + 1,0,M_B_Color);
- Read_Key;
- Return_Int := (Key2 shl 8) or Key1;
-
- RM('MAKEKEY /K1=' + Str(Key1) + '/K2=' + Str(key2));
- Kill_Box;
-
- END_MACRO;
-
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: MakeKeyMac
-
- Description: Takes the keystroke macro information and puts it into
- a global variable.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
- $MACRO MakeKeyMac;
- def_int(count,K_Int);
-
- {Flush the keystroke buffer}
- count := 0;
- WHILE (check_key) AND (count < 100) DO
- ++count;
- END;
- {Add the macro to the list}
- RM('KEYMAC^KEYMAC_LOAD /KW=1/LM=1/M=' + Str(Mode + 1));
- {Pop up the list and immediately get into the data_in screen for the new macro}
- Push_Key(0,61);
- RM('KEYMAC_LIST /S=' + Str(Return_int));
- Update_Status_Line;
- EXIT:
- END_MACRO;