added a couple keys to console/key, and added append to string
This commit is contained in:
parent
3f5e631388
commit
7f0120f0c8
4 changed files with 60 additions and 3 deletions
|
|
@ -54,6 +54,8 @@ typedef enum ARC_ConsoleKey_Key {
|
|||
ARC_KEY_DOWN,
|
||||
ARC_KEY_UP,
|
||||
|
||||
ARC_KEY_BACKSPACE,
|
||||
|
||||
ARC_KEY_ESC
|
||||
} ARC_ConsoleKey_Key;
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,35 @@ void ARC_String_ReplaceWithSubstring(ARC_String **string, uint64_t start, uint64
|
|||
*/
|
||||
void ARC_String_RemoveSubstring(ARC_String **newString, ARC_String *original, ARC_String *substring);
|
||||
|
||||
/**
|
||||
* @brief appends to an ARC_String with an ARC_String
|
||||
*
|
||||
* @note this uses ARC_String_AppendCString, so debug logs will be thrown in that function not this one
|
||||
*
|
||||
* @param string the string to add to, will not change on error
|
||||
* @param append the string that will be added to the back of string
|
||||
*/
|
||||
void ARC_String_Append(ARC_String **string, ARC_String *append);
|
||||
|
||||
/**
|
||||
* @brief appends to an ARC_String with an ARC_String
|
||||
*
|
||||
* @param string the string to add to, will not change on error
|
||||
* @param cstring the cstring that will be added to the back of string
|
||||
* @param length the length of the cstring that is being added
|
||||
*/
|
||||
void ARC_String_AppendCString(ARC_String **string, const char *cstring, uint64_t length);
|
||||
|
||||
/**
|
||||
* @brief appends to an ARC_String with an ARC_String
|
||||
*
|
||||
* @note this uses ARC_String_AppendCString, so debug logs will be thrown in that function not this one
|
||||
*
|
||||
* @param string the string to add to, will not change on error
|
||||
* @param cstring the cstring that will be added to the back of string
|
||||
*/
|
||||
void ARC_String_AppendCStringWithStrlen(ARC_String **string, const char *cstring);
|
||||
|
||||
/**
|
||||
* @brief checks if two strings are the same
|
||||
*
|
||||
|
|
|
|||
|
|
@ -147,6 +147,9 @@ ARC_ConsoleKey ARC_Keyboard_GetConsoleKey(enum ARC_ConsoleKey_Key key){
|
|||
case ARC_KEY_RIGHT:
|
||||
return (ARC_ConsoleKey){ KEY_RIGHT };
|
||||
|
||||
case ARC_KEY_BACKSPACE:
|
||||
return (ARC_ConsoleKey){ KEY_BACKSPACE };
|
||||
|
||||
//TODO: This is escape and alt, need to fix
|
||||
case ARC_KEY_ESC:
|
||||
return (ARC_ConsoleKey){ 27 };
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ void ARC_String_Create(ARC_String **string, char *data, uint64_t length){
|
|||
(*string)->data = (char *)malloc(sizeof(char) * (length + 1));
|
||||
(*string)->length = length;
|
||||
|
||||
if(length > 0){
|
||||
strncpy((*string)->data, data, length);
|
||||
}
|
||||
(*string)->data[length] = '\0';
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +97,27 @@ void ARC_String_RemoveSubstring(ARC_String **newString, ARC_String *original, AR
|
|||
ARC_String_RemoveSection(newString, original, index, original->length);
|
||||
}
|
||||
|
||||
void ARC_String_Append(ARC_String **string, ARC_String *append){
|
||||
ARC_String_AppendCString(string, append->data, append->length);
|
||||
}
|
||||
|
||||
void ARC_String_AppendCString(ARC_String **string, const char *cstring, uint64_t length){
|
||||
char *data = (char *)malloc(sizeof((*string)->length + length + 1));
|
||||
|
||||
strncpy(data, (*string)->data, (*string)->length);
|
||||
strncpy(data + (*string)->length, cstring, length);
|
||||
data[(*string)->length + length] = '\0';
|
||||
|
||||
free((*string)->data);
|
||||
|
||||
(*string)->data = data;
|
||||
(*string)->length = (*string)->length + length;
|
||||
}
|
||||
|
||||
void ARC_String_AppendCStringWithStrlen(ARC_String **string, const char *cstring){
|
||||
ARC_String_AppendCString(string, cstring, strlen(cstring));
|
||||
}
|
||||
|
||||
ARC_Bool ARC_String_Equals(ARC_String *first, ARC_String *second){
|
||||
if(first->length != second->length){
|
||||
return ARC_False;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue