@@ -998,7 +998,7 @@ typedef enum {
998998 ICON_LAYERS2 = 225 ,
999999 ICON_MLAYERS = 226 ,
10001000 ICON_MAPS = 227 ,
1001- ICON_228 = 228 ,
1001+ ICON_HOT = 228 ,
10021002 ICON_229 = 229 ,
10031003 ICON_230 = 230 ,
10041004 ICON_231 = 231 ,
@@ -1045,6 +1045,7 @@ typedef enum {
10451045
10461046#if defined(RAYGUI_IMPLEMENTATION )
10471047
1048+ #include <ctype.h> // required for: isspace() [GuiTextBox()]
10481049#include <stdio.h> // Required for: FILE, fopen(), fclose(), fprintf(), feof(), fscanf(), vsprintf() [GuiLoadStyle(), GuiLoadIcons()]
10491050#include <stdlib.h> // Required for: malloc(), calloc(), free() [GuiLoadStyle(), GuiLoadIcons()]
10501051#include <string.h> // Required for: strlen() [GuiTextBox(), GuiValueBox()], memset(), memcpy()
@@ -1316,7 +1317,7 @@ static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] =
13161317 0x07fe0000 , 0x1c020402 , 0x74021402 , 0x54025402 , 0x54025402 , 0x500857fe , 0x40205ff8 , 0x00007fe0 , // ICON_LAYERS2
13171318 0x0ffe0000 , 0x3ffa0802 , 0x7fea200a , 0x402a402a , 0x422a422a , 0x422e422a , 0x40384e28 , 0x00007fe0 , // ICON_MLAYERS
13181319 0x0ffe0000 , 0x3ffa0802 , 0x7fea200a , 0x402a402a , 0x5b2a512a , 0x512e552a , 0x40385128 , 0x00007fe0 , // ICON_MAPS
1319- 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , // ICON_228
1320+ 0x04200000 , 0x1cf00c60 , 0x11f019f0 , 0x0f3807b8 , 0x1e3c0f3c , 0x1c1c1e1c , 0x1e3c1c1c , 0x00000f70 , // ICON_HOT
13201321 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , // ICON_229
13211322 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , // ICON_230
13221323 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , 0x00000000 , // ICON_231
@@ -1639,9 +1640,9 @@ int GuiGroupBox(Rectangle bounds, const char *text)
16391640
16401641 // Draw control
16411642 //--------------------------------------------------------------------
1642- GuiDrawRectangle (RAYGUI_CLITERAL (Rectangle ){ bounds .x , bounds .y , RAYGUI_GROUPBOX_LINE_THICK , bounds .height }, 0 , BLANK , GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? BORDER_COLOR_DISABLED : LINE_COLOR )));
1643- GuiDrawRectangle (RAYGUI_CLITERAL (Rectangle ){ bounds .x , bounds .y + bounds .height - 1 , bounds .width , RAYGUI_GROUPBOX_LINE_THICK }, 0 , BLANK , GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? BORDER_COLOR_DISABLED : LINE_COLOR )));
1644- GuiDrawRectangle (RAYGUI_CLITERAL (Rectangle ){ bounds .x + bounds .width - 1 , bounds .y , RAYGUI_GROUPBOX_LINE_THICK , bounds .height }, 0 , BLANK , GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? BORDER_COLOR_DISABLED : LINE_COLOR )));
1643+ GuiDrawRectangle (RAYGUI_CLITERAL (Rectangle ){ bounds .x , bounds .y , RAYGUI_GROUPBOX_LINE_THICK , bounds .height }, 0 , BLANK , GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? ( int ) BORDER_COLOR_DISABLED : ( int ) LINE_COLOR )));
1644+ GuiDrawRectangle (RAYGUI_CLITERAL (Rectangle ){ bounds .x , bounds .y + bounds .height - 1 , bounds .width , RAYGUI_GROUPBOX_LINE_THICK }, 0 , BLANK , GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? ( int ) BORDER_COLOR_DISABLED : ( int ) LINE_COLOR )));
1645+ GuiDrawRectangle (RAYGUI_CLITERAL (Rectangle ){ bounds .x + bounds .width - 1 , bounds .y , RAYGUI_GROUPBOX_LINE_THICK , bounds .height }, 0 , BLANK , GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? ( int ) BORDER_COLOR_DISABLED : ( int ) LINE_COLOR )));
16451646
16461647 GuiLine (RAYGUI_CLITERAL (Rectangle ){ bounds .x , bounds .y - GuiGetStyle (DEFAULT , TEXT_SIZE )/2 , bounds .width , (float )GuiGetStyle (DEFAULT , TEXT_SIZE ) }, text );
16471648 //--------------------------------------------------------------------
@@ -1662,7 +1663,7 @@ int GuiLine(Rectangle bounds, const char *text)
16621663 int result = 0 ;
16631664 GuiState state = guiState ;
16641665
1665- Color color = GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? BORDER_COLOR_DISABLED : LINE_COLOR ));
1666+ Color color = GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? ( int ) BORDER_COLOR_DISABLED : ( int ) LINE_COLOR ));
16661667
16671668 // Draw control
16681669 //--------------------------------------------------------------------
@@ -1710,7 +1711,7 @@ int GuiPanel(Rectangle bounds, const char *text)
17101711 //--------------------------------------------------------------------
17111712 if (text != NULL ) GuiStatusBar (statusBar , text ); // Draw panel header as status bar
17121713
1713- GuiDrawRectangle (bounds , RAYGUI_PANEL_BORDER_WIDTH , GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? BORDER_COLOR_DISABLED : LINE_COLOR )),
1714+ GuiDrawRectangle (bounds , RAYGUI_PANEL_BORDER_WIDTH , GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? ( int ) BORDER_COLOR_DISABLED : ( int ) LINE_COLOR )),
17141715 GetColor (GuiGetStyle (DEFAULT , (state == STATE_DISABLED )? BASE_COLOR_DISABLED : BACKGROUND_COLOR )));
17151716 //--------------------------------------------------------------------
17161717
@@ -2603,24 +2604,59 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
26032604 }
26042605 }
26052606
2606- // Delete codepoint from text, before current cursor position
2607- if ((textLength > 0 ) && ( IsKeyPressed (KEY_BACKSPACE ) || (IsKeyDown (KEY_BACKSPACE ) && ( autoCursorCooldownCounter >= RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN ) )))
2607+ // Delete related codepoints from text, before current cursor position
2608+ if ((textLength > 0 ) && IsKeyPressed (KEY_BACKSPACE ) && (IsKeyDown (KEY_LEFT_CONTROL ) || IsKeyDown ( KEY_RIGHT_CONTROL )))
26082609 {
2609- autoCursorDelayCounter ++ ;
2610+ int i = textBoxCursorIndex - 1 ;
2611+ int accCodepointSize = 0 ;
26102612
2611- if (IsKeyPressed (KEY_BACKSPACE ) || (autoCursorDelayCounter %RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY ) == 0 ) // Delay every movement some frames
2613+ // Move cursor to the end of word if on space already
2614+ while ((i > 0 ) && isspace (text [i ]))
26122615 {
26132616 int prevCodepointSize = 0 ;
2614- GetCodepointPrevious (text + textBoxCursorIndex , & prevCodepointSize );
2617+ GetCodepointPrevious (text + i , & prevCodepointSize );
2618+ i -= prevCodepointSize ;
2619+ accCodepointSize += prevCodepointSize ;
2620+ }
26152621
2616- // Move backward text from cursor position
2617- for (int i = (textBoxCursorIndex - prevCodepointSize ); i < textLength ; i ++ ) text [i ] = text [i + prevCodepointSize ];
2622+ // Move cursor to the start of the word
2623+ while ((i > 0 ) && !isspace (text [i ]))
2624+ {
2625+ int prevCodepointSize = 0 ;
2626+ GetCodepointPrevious (text + i , & prevCodepointSize );
2627+ i -= prevCodepointSize ;
2628+ accCodepointSize += prevCodepointSize ;
2629+ }
26182630
2619- // TODO Check: >= cursor+codepointsize and <= length-codepointsize
2631+ // Move forward text from cursor position
2632+ for (int j = (textBoxCursorIndex - accCodepointSize ); j < textLength ; j ++ ) text [j ] = text [j + accCodepointSize ];
2633+
2634+ // Prevent cursor index from decrementing past 0
2635+ if (textBoxCursorIndex > 0 )
2636+ {
2637+ textBoxCursorIndex -= accCodepointSize ;
2638+ textLength -= accCodepointSize ;
2639+ }
2640+
2641+ // Make sure text last character is EOL
2642+ text [textLength ] = '\0' ;
2643+ }
2644+ else if ((textLength > 0 ) && (IsKeyPressed (KEY_BACKSPACE ) || (IsKeyDown (KEY_BACKSPACE ) && (autoCursorCooldownCounter >= RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN ))))
2645+ {
2646+ autoCursorDelayCounter ++ ;
2647+
2648+ if (IsKeyPressed (KEY_BACKSPACE ) || (autoCursorDelayCounter %RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY ) == 0 ) // Delay every movement some frames
2649+ {
2650+ int prevCodepointSize = 0 ;
26202651
26212652 // Prevent cursor index from decrementing past 0
26222653 if (textBoxCursorIndex > 0 )
26232654 {
2655+ GetCodepointPrevious (text + textBoxCursorIndex , & prevCodepointSize );
2656+
2657+ // Move backward text from cursor position
2658+ for (int i = (textBoxCursorIndex - prevCodepointSize ); i < textLength ; i ++ ) text [i ] = text [i + prevCodepointSize ];
2659+
26242660 textBoxCursorIndex -= codepointSize ;
26252661 textLength -= codepointSize ;
26262662 }
@@ -2638,7 +2674,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
26382674 if (IsKeyPressed (KEY_LEFT ) || (autoCursorDelayCounter %RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY ) == 0 ) // Delay every movement some frames
26392675 {
26402676 int prevCodepointSize = 0 ;
2641- GetCodepointPrevious (text + textBoxCursorIndex , & prevCodepointSize );
2677+ if ( textBoxCursorIndex > 0 ) GetCodepointPrevious (text + textBoxCursorIndex , & prevCodepointSize );
26422678
26432679 if (textBoxCursorIndex >= prevCodepointSize ) textBoxCursorIndex -= prevCodepointSize ;
26442680 }
@@ -3426,7 +3462,7 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *scrollInd
34263462
34273463 // Draw control
34283464 //--------------------------------------------------------------------
3429- GuiDrawRectangle (bounds , GuiGetStyle (DEFAULT , BORDER_WIDTH ), GetColor (GuiGetStyle (LISTVIEW , BORDER + state * 3 )), GetColor (GuiGetStyle (DEFAULT , BACKGROUND_COLOR ))); // Draw background
3465+ GuiDrawRectangle (bounds , GuiGetStyle (LISTVIEW , BORDER_WIDTH ), GetColor (GuiGetStyle (LISTVIEW , BORDER + state * 3 )), GetColor (GuiGetStyle (DEFAULT , BACKGROUND_COLOR ))); // Draw background
34303466
34313467 // Draw visible items
34323468 for (int i = 0 ; ((i < visibleItems ) && (text != NULL )); i ++ )
@@ -3881,7 +3917,7 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons
38813917 buttonBounds .width = (bounds .width - RAYGUI_MESSAGEBOX_BUTTON_PADDING * (buttonCount + 1 ))/buttonCount ;
38823918 buttonBounds .height = RAYGUI_MESSAGEBOX_BUTTON_HEIGHT ;
38833919
3884- int textWidth = GetTextWidth (message ) + 2 ;
3920+ // int textWidth = GetTextWidth(message) + 2;
38853921
38863922 Rectangle textBounds = { 0 };
38873923 textBounds .x = bounds .x + RAYGUI_MESSAGEBOX_BUTTON_PADDING ;
@@ -4485,7 +4521,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
44854521 // NOTE: All DEFAULT properties should be defined first in the file
44864522 GuiSetStyle (0 , (int )propertyId , propertyValue );
44874523
4488- if (propertyId < RAYGUI_MAX_PROPS_BASE ) for (int i = 1 ; i < RAYGUI_MAX_CONTROLS ; i ++ ) GuiSetStyle (i , (int )propertyId , propertyValue );
4524+ if (propertyId < RAYGUI_MAX_PROPS_BASE ) for (int j = 1 ; j < RAYGUI_MAX_CONTROLS ; j ++ ) GuiSetStyle (j , (int )propertyId , propertyValue );
44894525 }
44904526 else GuiSetStyle ((int )controlId , (int )propertyId , propertyValue );
44914527 }
@@ -5718,4 +5754,4 @@ static int GetCodepointNext(const char *text, int *codepointSize)
57185754}
57195755#endif // RAYGUI_STANDALONE
57205756
5721- #endif // RAYGUI_IMPLEMENTATION
5757+ #endif // RAYGUI_IMPLEMENTATION
0 commit comments