mirror of
https://github.com/digarok/gsplus.git
synced 2025-08-12 06:25:27 +00:00
use SDL function to get clipboard text for F5 paste.
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <string.h>
|
||||||
#include "defc.h"
|
#include "defc.h"
|
||||||
|
|
||||||
// BITMASKS
|
// BITMASKS
|
||||||
@@ -555,9 +556,59 @@ void x_full_screen(int do_full) { }
|
|||||||
void x_release_kimage(Kimage* kimage_ptr) { }
|
void x_release_kimage(Kimage* kimage_ptr) { }
|
||||||
// OG Addding ratio
|
// OG Addding ratio
|
||||||
int x_calc_ratio(float x,float y) { return 1; }
|
int x_calc_ratio(float x,float y) { return 1; }
|
||||||
// TODO: Add clipboard support
|
|
||||||
void clipboard_paste(void) { }
|
|
||||||
int clipboard_get_char(void) { return 0; }
|
static char *g_clipboard = NULL;
|
||||||
|
static size_t g_clipboard_pos = 0;
|
||||||
|
|
||||||
|
void clipboard_paste(void) {
|
||||||
|
|
||||||
|
char *cp;
|
||||||
|
|
||||||
|
if (g_clipboard) {
|
||||||
|
free(g_clipboard);
|
||||||
|
g_clipboard = NULL;
|
||||||
|
g_clipboard_pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cp = SDL_GetClipboardText();
|
||||||
|
if (!cp) return;
|
||||||
|
|
||||||
|
g_clipboard = strdup(cp);
|
||||||
|
g_clipboard_pos = 0;
|
||||||
|
|
||||||
|
SDL_free(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
int clipboard_get_char(void) {
|
||||||
|
char c;
|
||||||
|
|
||||||
|
if (!g_clipboard)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// skip utf-8 characters.
|
||||||
|
for (;;) {
|
||||||
|
c = g_clipboard[g_clipboard_pos++];
|
||||||
|
if (c & 0x80) {
|
||||||
|
/* utf8 sequence */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c == '\n') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == 0) {
|
||||||
|
free(g_clipboard);
|
||||||
|
g_clipboard = NULL;
|
||||||
|
g_clipboard_pos = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return c | 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
void x_set_mask_and_shift(word32 x_mask, word32 *mask_ptr, int *shift_left_ptr, int *shift_right_ptr) { return; }
|
void x_set_mask_and_shift(word32 x_mask, word32 *mask_ptr, int *shift_left_ptr, int *shift_right_ptr) { return; }
|
||||||
void x_update_color(int col_num, int red, int green, int blue, word32 rgb) { }
|
void x_update_color(int col_num, int red, int green, int blue, word32 rgb) { }
|
||||||
void x_update_physical_colormap() { }
|
void x_update_physical_colormap() { }
|
||||||
|
Reference in New Issue
Block a user