本文整理汇总了C++中SDL_SetClipboardText函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_SetClipboardText函数的具体用法?C++ SDL_SetClipboardText怎么用?C++ SDL_SetClipboardText使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_SetClipboardText函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mrb_sdl2_clipboard_set_text
static mrb_value
mrb_sdl2_clipboard_set_text(mrb_state *mrb, mrb_value self)
{
mrb_value text;
mrb_get_args(mrb, "S", &text);
SDL_SetClipboardText(RSTRING_PTR(text));
return text;
}
示例2: put_scrap
// When (if?) we decide to put text into the clipboard...
bool put_scrap(char *src)
{
if (SDL_SetClipboardText(src))
{
debug(LOG_ERROR, "Could not put clipboard text because : %s", SDL_GetError());
return false;
}
return true;
}
示例3: PDC_setclipboard
int PDC_setclipboard(const char *contents, long length)
{
PDC_LOG(("PDC_setclipboard() - called\n"));
if (SDL_SetClipboardText(contents) != 0)
return PDC_CLIP_ACCESS_ERROR;
return PDC_CLIP_SUCCESS;
}
示例4: PDC_clearclipboard
int PDC_clearclipboard(void)
{
PDC_LOG(("PDC_clearclipboard() - called\n"));
if (SDL_HasClipboardText() == SDL_TRUE)
{
SDL_SetClipboardText(NULL);
}
return PDC_CLIP_SUCCESS;
}
示例5: SDL_SetClipboardText
bool TextBox::copySelection() {
if (mSelectionPos > -1) {
Screen *sc = dynamic_cast<Screen *>(this->window()->parent());
int begin = mCursorPos;
int end = mSelectionPos;
if (begin > end)
std::swap(begin, end);
SDL_SetClipboardText(mValueTemp.substr(begin, end).c_str());
return true;
}
return false;
}
示例6: textinput
//texto por teclado
bool textinput(std::string *inputText, bool renderText, SDL_Event e)
{
if( e.type == SDL_KEYDOWN )
{
//permite introducir texto
SDL_StartTextInput();
//Handle backspace
if( e.key.keysym.sym == SDLK_BACKSPACE && inputText->length() > 0 )
{
//lop off character
inputText->pop_back();
renderText = true;
}
//Handle copy
else if( e.key.keysym.sym == SDLK_c && SDL_GetModState() & KMOD_CTRL )
{
SDL_SetClipboardText( inputText->c_str() );
}
//Handle paste
//esta comentado porq me da un error
/*else if( e.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL )
{
inputText = SDL_GetClipboardText();
renderText = true;
}*/
}
//Special text input event
else if( e.type == SDL_TEXTINPUT )
{
//Not copy or pasting
if( !( ( e.text.text[ 0 ] == 'c' || e.text.text[ 0 ] == 'C' ) && ( e.text.text[ 0 ] == 'v' || e.text.text[ 0 ] == 'V' ) && SDL_GetModState() & KMOD_CTRL ) )
{
//Append character
inputText->append(e.text.text);
renderText = true;
}
}
//devuelve si hay que renderizar el texto
return renderText;
//cierra la comunicacion con el telclado
SDL_StopTextInput();
}
示例7: catch
/*
* Gets Coordinates from the screen already translated to
* Screen Buffer Positions, Now we pull the position and throw the
* Text data into the Clipboard.
*/
void ScreenBuffer::bufferToClipboard(int startx, int starty, int numChar, int numRows)
{
std::string textBuffer = "";
int startPosition = (starty * characters_per_line) + startx;
int endPosition = startPosition + numChar;
// Loop the Number of Rows to Grab
for(int ot = 0; ot < numRows; ot++)
{
// Grab each line per Row.
for(int it = startPosition; it < endPosition; it++)
{
try
{
if(screenBuffer[it].characterSequence != "")
{
textBuffer += screenBuffer[it].characterSequence;
}
else
{
textBuffer += " ";
}
}
catch(std::exception &e)
{
std::cout << "Exception bufferToClipboard: " << e.what() << std::endl;
}
}
// Add Newline at the end of each row.
textBuffer += "\r\n";
// Reset start/end position to next Row.
startPosition += characters_per_line;
endPosition += characters_per_line;
}
// Copy Resulting text to the Clipboard.
SDL_SetClipboardText(textBuffer.c_str());
}
示例8: clipboard_testSetClipboardText
/**
* \brief Check call to SDL_SetClipboardText
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
*/
int
clipboard_testSetClipboardText(void *arg)
{
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
int result;
result = SDL_SetClipboardText((const char *)text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
result == 0,
"Validate SDL_SetClipboardText result, expected 0, got %i",
result);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
textRef, text);
/* Cleanup */
if (textRef) SDL_free(textRef);
if (text) SDL_free(text);
return TEST_COMPLETED;
}
示例9: clipboard_set
static void
clipboard_set(const char *text)
{SDL_SetClipboardText(text);}
示例10: clipboard_testClipboardTextFunctions
/**
* \brief End-to-end test of SDL_xyzClipboardText functions
* \sa
* http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText
* http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText
* http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText
*/
int
clipboard_testClipboardTextFunctions(void *arg)
{
char *textRef = SDLTest_RandomAsciiString();
char *text = SDL_strdup(textRef);
SDL_bool boolResult;
int intResult;
char *charResult;
/* Clear clipboard text state */
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
if (boolResult == SDL_TRUE) {
intResult = SDL_SetClipboardText((const char *)NULL);
SDLTest_AssertPass("Call to SDL_SetClipboardText(NULL) succeeded");
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult);
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDLTest_AssertCheck(
boolResult == SDL_FALSE,
"Verify SDL_HasClipboardText returned SDL_FALSE, got %s",
(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
}
/* Empty clipboard */
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDLTest_AssertCheck(
charResult != NULL,
"Verify SDL_GetClipboardText did not return NULL");
SDLTest_AssertCheck(
SDL_strlen(charResult) == 0,
"Verify SDL_GetClipboardText returned string with length 0, got length %i",
SDL_strlen(charResult));
intResult = SDL_SetClipboardText((const char *)text);
SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
SDLTest_AssertCheck(
intResult == 0,
"Verify result from SDL_SetClipboardText(NULL), expected 0, got %i",
intResult);
SDLTest_AssertCheck(
SDL_strcmp(textRef, text) == 0,
"Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'",
textRef, text);
boolResult = SDL_HasClipboardText();
SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded");
SDLTest_AssertCheck(
boolResult == SDL_TRUE,
"Verify SDL_HasClipboardText returned SDL_TRUE, got %s",
(boolResult) ? "SDL_TRUE" : "SDL_FALSE");
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
SDLTest_AssertCheck(
SDL_strcmp(textRef, charResult) == 0,
"Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'",
textRef, charResult);
/* Cleanup */
if (textRef) SDL_free(textRef);
if (text) SDL_free(text);
if (charResult) SDL_free(charResult);
return TEST_COMPLETED;
}
示例11: WatchJoystick
static SDL_bool
WatchJoystick(SDL_Joystick * joystick)
{
SDL_Window *window = NULL;
SDL_Renderer *screen = NULL;
SDL_Texture *background, *button, *axis, *marker;
const char *name = NULL;
SDL_bool retval = SDL_FALSE;
SDL_bool done = SDL_FALSE, next=SDL_FALSE;
SDL_Event event;
SDL_Rect dst;
int s, _s;
Uint8 alpha=200, alpha_step = -1;
Uint32 alpha_ticks;
char mapping[4096], temp[4096];
MappingStep *step;
MappingStep steps[] = {
{342, 132, 0.0, MARKER_BUTTON, "x", -1, -1, -1, -1, ""},
{387, 167, 0.0, MARKER_BUTTON, "a", -1, -1, -1, -1, ""},
{431, 132, 0.0, MARKER_BUTTON, "b", -1, -1, -1, -1, ""},
{389, 101, 0.0, MARKER_BUTTON, "y", -1, -1, -1, -1, ""},
{174, 132, 0.0, MARKER_BUTTON, "back", -1, -1, -1, -1, ""},
{233, 132, 0.0, MARKER_BUTTON, "guide", -1, -1, -1, -1, ""},
{289, 132, 0.0, MARKER_BUTTON, "start", -1, -1, -1, -1, ""},
{116, 217, 0.0, MARKER_BUTTON, "dpleft", -1, -1, -1, -1, ""},
{154, 249, 0.0, MARKER_BUTTON, "dpdown", -1, -1, -1, -1, ""},
{186, 217, 0.0, MARKER_BUTTON, "dpright", -1, -1, -1, -1, ""},
{154, 188, 0.0, MARKER_BUTTON, "dpup", -1, -1, -1, -1, ""},
{77, 40, 0.0, MARKER_BUTTON, "leftshoulder", -1, -1, -1, -1, ""},
{91, 0, 0.0, MARKER_BUTTON, "lefttrigger", -1, -1, -1, -1, ""},
{396, 36, 0.0, MARKER_BUTTON, "rightshoulder", -1, -1, -1, -1, ""},
{375, 0, 0.0, MARKER_BUTTON, "righttrigger", -1, -1, -1, -1, ""},
{75, 154, 0.0, MARKER_BUTTON, "leftstick", -1, -1, -1, -1, ""},
{305, 230, 0.0, MARKER_BUTTON, "rightstick", -1, -1, -1, -1, ""},
{75, 154, 0.0, MARKER_AXIS, "leftx", -1, -1, -1, -1, ""},
{75, 154, 90.0, MARKER_AXIS, "lefty", -1, -1, -1, -1, ""},
{305, 230, 0.0, MARKER_AXIS, "rightx", -1, -1, -1, -1, ""},
{305, 230, 90.0, MARKER_AXIS, "righty", -1, -1, -1, -1, ""},
};
/* Create a window to display joystick axis position */
window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return SDL_FALSE;
}
screen = SDL_CreateRenderer(window, -1, 0);
if (screen == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_DestroyWindow(window);
return SDL_FALSE;
}
background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE);
button = LoadTexture(screen, "button.bmp", SDL_TRUE);
axis = LoadTexture(screen, "axis.bmp", SDL_TRUE);
SDL_RaiseWindow(window);
/* scale for platforms that don't give you the window size you asked for. */
SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT);
/* Print info about the joystick we are watching */
name = SDL_JoystickName(joystick);
SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
name ? name : "Unknown Joystick");
SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
SDL_Log("\n\n\
====================================================================================\n\
Press the buttons on your controller when indicated\n\
(Your controller may look different than the picture)\n\
If you want to correct a mistake, press backspace or the back button on your device\n\
To skip a button, press SPACE or click/touch the screen\n\
To exit, press ESC\n\
====================================================================================\n");
/* Initialize mapping with GUID and name */
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), temp, SDL_arraysize(temp));
SDL_snprintf(mapping, SDL_arraysize(mapping), "%s,%s,platform:%s,",
temp, name ? name : "Unknown Joystick", SDL_GetPlatform());
/* Loop, getting joystick events! */
for(s=0; s<SDL_arraysize(steps) && !done;) {
/* blank screen, set up for drawing this frame. */
step = &steps[s];
SDL_strlcpy(step->mapping, mapping, SDL_arraysize(step->mapping));
step->axis = -1;
step->button = -1;
step->hat = -1;
step->hat_value = -1;
SDL_SetClipboardText("TESTING TESTING 123");
switch(step->marker) {
case MARKER_AXIS:
marker = axis;
//.........这里部分代码省略.........
示例12: system_setClipboardText
void system_setClipboardText(const char* text)
{
moduleData.clipboardText = text;
SDL_SetClipboardText(text);
}
示例13: ImGui_ImplSdlGL3_SetClipboardText
static void ImGui_ImplSdlGL3_SetClipboardText(const char* text)
{
SDL_SetClipboardText(text);
}
示例14: SDLTest_CommonEvent
void
SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
{
int i;
static SDL_MouseMotionEvent lastEvent;
if (state->verbose & VERBOSE_EVENT) {
SDLTest_PrintEvent(event);
}
switch (event->type) {
case SDL_WINDOWEVENT:
switch (event->window.event) {
case SDL_WINDOWEVENT_CLOSE:
{
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
if (window) {
SDL_DestroyWindow(window);
}
}
break;
}
break;
case SDL_KEYDOWN:
switch (event->key.keysym.sym) {
/* Add hotkeys here */
case SDLK_PRINTSCREEN: {
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
for (i = 0; i < state->num_windows; ++i) {
if (window == state->windows[i]) {
SDLTest_ScreenShot(state->renderers[i]);
}
}
}
}
break;
case SDLK_EQUALS:
if (event->key.keysym.mod & KMOD_CTRL) {
/* Ctrl-+ double the size of the window */
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
int w, h;
SDL_GetWindowSize(window, &w, &h);
SDL_SetWindowSize(window, w*2, h*2);
}
}
break;
case SDLK_MINUS:
if (event->key.keysym.mod & KMOD_CTRL) {
/* Ctrl-- half the size of the window */
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
int w, h;
SDL_GetWindowSize(window, &w, &h);
SDL_SetWindowSize(window, w/2, h/2);
}
}
break;
case SDLK_c:
if (event->key.keysym.mod & KMOD_CTRL) {
/* Ctrl-C copy awesome text! */
SDL_SetClipboardText("SDL rocks!\nYou know it!");
printf("Copied text to clipboard\n");
}
if (event->key.keysym.mod & KMOD_ALT) {
/* Alt-C toggle a render clip rectangle */
for (i = 0; i < state->num_windows; ++i) {
int w, h;
if (state->renderers[i]) {
SDL_Rect clip;
SDL_GetWindowSize(state->windows[i], &w, &h);
SDL_RenderGetClipRect(state->renderers[i], &clip);
if (SDL_RectEmpty(&clip)) {
clip.x = w/4;
clip.y = h/4;
clip.w = w/2;
clip.h = h/2;
SDL_RenderSetClipRect(state->renderers[i], &clip);
} else {
SDL_RenderSetClipRect(state->renderers[i], NULL);
}
}
}
}
break;
case SDLK_v:
if (event->key.keysym.mod & KMOD_CTRL) {
/* Ctrl-V paste awesome text! */
char *text = SDL_GetClipboardText();
if (*text) {
printf("Clipboard: %s\n", text);
} else {
printf("Clipboard is empty\n");
}
SDL_free(text);
}
break;
case SDLK_g:
if (event->key.keysym.mod & KMOD_CTRL) {
//.........这里部分代码省略.........
示例15: SDL_SetClipboardText
void WindowSDL::setClipboardText(const std::string & text) {
const auto result = SDL_SetClipboardText(text.c_str());
if(result != 0) {
WARN(std::string("SDL_SetClipboardText failed: ") + SDL_GetError());
}
}