home *** CD-ROM | disk | FTP | other *** search
- /*
- ** This file contains functions to give name to hotkey converted
- ** from Yak 1.x to Yak 2.x
- */
-
-
-
-
- #include <exec/types.h>
- #include <ctype.h>
- #include <libraries/commodities.h>
-
- #include "code.h"
- #include "yak.h"
- #include "hotkey_types.h"
- #include "hotkey_naming.h"
-
- #define CATCOMP_BLOCK
- #define CATCOMP_NUMBERS
- #include "locale/yak_locale_strings.h"
- #undef CATCOMP_BLOCK
-
- #define MAX_LENGTH_NAME 100
-
- static char NewName[100];
-
- void
- ColorUp (char *I_Str, char *O_Str)
- {
- UBYTE n = 0;
- BOOL FirstWord = TRUE;
-
- while ((*I_Str != '\0') && (n < MAX_LENGTH_NAME-1))
- {
- if ((*I_Str == ' ') || (FirstWord == TRUE))
- {
- while ((*I_Str != '\0') && (*I_Str == ' '))
- {
- /* Skip white space */
- ++I_Str;
- };
-
- /* Capitalize first char after white space */
- if (*I_Str != '\0')
- {
- *O_Str = toupper(*I_Str);
- ++O_Str;
- n++;
-
- FirstWord = FALSE;
- }
-
- }
- else
- {
- /* Copy other chars */
- *O_Str = *I_Str;
- ++O_Str;
- }
-
- if (*I_Str != '\0')
- {
- ++I_Str;
- n++;
- }
- }
- *O_Str = '\0';
- }
-
-
-
- void
- FirstWord (char *I_Str, char *O_Str)
- {
- UBYTE n = 0;
-
- while ((*I_Str != '\0') && (*I_Str == ' ') && (n < MAX_LENGTH_NAME-1))
- {
- /* Skip white space */
- ++I_Str;
- };
-
- /* Capitalize first char after white space */
- if (*I_Str != '\0')
- {
- *O_Str = toupper(*I_Str);
- ++O_Str;
- ++I_Str;
- n++;
- }
-
- while ((*I_Str != '\0') && (*I_Str != ' ') && (n < MAX_LENGTH_NAME-1))
- {
- /* Copy other chars */
- *O_Str = *I_Str;
- ++O_Str;
- ++I_Str;
- n++;
- }
-
- *O_Str = '\0';
- ++O_Str;
- }
-
-
- void
- AutomaticNaming (YakHotKey *yhk)
- {
- switch(yhk->yhk_Type)
- {
- case EXECUTE_COMMAND:
- /* Name will be generated from the command to execute */
- FirstWord(yhk->yhk_Option[1].ArgStr[0], NewName);
- break;
-
- case INSERT_TEXT:
- /* Name will be generated from the text to insert */
- ColorUp(yhk->yhk_Option[0].ArgStr[0], NewName);
- break;
-
- default:
- /* Name will be generated from the localized name of the action */
- ColorUp(getString(yhktypes[yhk->yhk_Type].yhkt_nameID), NewName);
- break;
- }
-
- ModifyYHKName(yhk, NewName);
- }
-