|
|
@ -104,6 +104,27 @@ pub fn main() !void {
|
|
104
|
104
|
msg[max_chars] = 0;
|
|
105
|
105
|
pos = 0;
|
|
106
|
106
|
},
|
|
|
107
|
c.SDLK_c => {
|
|
|
108
|
const clipboard_text = try gpa.dupeZ(u8, result);
|
|
|
109
|
if (c.SDL_SetClipboardText(clipboard_text) != 0) {
|
|
|
110
|
c.SDL_Log("Could not set clipboard text: %s", c.SDL_GetError());
|
|
|
111
|
}
|
|
|
112
|
gpa.free(clipboard_text);
|
|
|
113
|
},
|
|
|
114
|
c.SDLK_v => {
|
|
|
115
|
const clipboard_text = c.SDL_GetClipboardText();
|
|
|
116
|
if (std.mem.len(clipboard_text) == 0) {
|
|
|
117
|
c.SDL_Log("Could not get clipboard: %s", c.SDL_GetError());
|
|
|
118
|
} else {
|
|
|
119
|
const initial_pos = pos;
|
|
|
120
|
while (pos < max_chars and pos - initial_pos < std.mem.len(clipboard_text)) : (pos += 1) {
|
|
|
121
|
msg[pos] = clipboard_text[pos - initial_pos];
|
|
|
122
|
}
|
|
|
123
|
msg[pos] = ' ';
|
|
|
124
|
msg[max_chars] = 0;
|
|
|
125
|
}
|
|
|
126
|
c.SDL_free(clipboard_text);
|
|
|
127
|
},
|
|
107
|
128
|
else => {},
|
|
108
|
129
|
}
|
|
109
|
130
|
} else {
|