Skip to content

Commit

Permalink
Check width before pasting text in console
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Aug 9, 2015
1 parent 1bd8d23 commit 928235c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/c_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,12 +1232,18 @@ dboolean C_Responder(event_t *ev)
// paste text from clipboard
else if (ch == 'v')
{
C_AddToUndoHistory();
M_snprintf(consoleinput, sizeof(consoleinput), "%s%s%s",
char buffer[255];

M_snprintf(buffer, sizeof(buffer), "%s%s%s",
M_SubString(consoleinput, 0, selectstart), SDL_GetClipboardText(),
M_SubString(consoleinput, selectend, strlen(consoleinput) - selectend));
selectstart += strlen(SDL_GetClipboardText());
selectend = caretpos = selectstart;
if (C_TextWidth(buffer) <= CONSOLEINPUTPIXELWIDTH)
{
C_AddToUndoHistory();
M_StringCopy(consoleinput, buffer, sizeof(consoleinput));
selectstart += strlen(SDL_GetClipboardText());
selectend = caretpos = selectstart;
}
}

// cut selected text to clipboard
Expand Down

0 comments on commit 928235c

Please sign in to comment.