Remove whitespaces when pasting a new palette

Im trying to solve issue https://github.com/nesbox/TIC-80/issues/455.
When copying a hex palette from the web, it palette may contain spaces, tabs or carriage commands (\r or \n).
Pasting it on TIC-80 will not work, making the users life difficult (they have to fix the string in an editor).

This commit enables pasting hex palettes with blank spaces.
This commit is contained in:
Guilherme Medeiros
2017-12-10 15:00:12 -03:00
parent 86a320e9ad
commit 67e6dc281f
4 changed files with 29 additions and 7 deletions

View File

@@ -648,8 +648,8 @@ static void drawRGBSlider(Sprite* sprite, s32 x, s32 y, u8* value)
static void pasteColor(Sprite* sprite)
{
fromClipboard(sprite->tic->cart.palette.data, sizeof(tic_palette), false);
fromClipboard(&sprite->tic->cart.palette.colors[sprite->color], sizeof(tic_rgb), false);
fromClipboard(sprite->tic->cart.palette.data, sizeof(tic_palette), false, true);
fromClipboard(&sprite->tic->cart.palette.colors[sprite->color], sizeof(tic_rgb), false, true);
}
static void drawRGBTools(Sprite* sprite, s32 x, s32 y)
@@ -1240,7 +1240,7 @@ static void copyFromClipboard(Sprite* sprite)
if(buffer)
{
if(fromClipboard(buffer, size, true))
if(fromClipboard(buffer, size, true, false))
{
SDL_Rect rect = getSpriteRect(sprite);
s32 r = rect.x + rect.w;