)
target_link_libraries(nothing ${SDL2_LIBRARIES})
-ADD_CUSTOM_TARGET(link_assets ALL
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets)
+if(WIN32)
+ ADD_CUSTOM_TARGET(link_assets ALL COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets)
+else()
+ ADD_CUSTOM_TARGET(link_assets ALL COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets)
+endif()
if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang"))
set(CMAKE_C_FLAGS
2
back_platform_0 -185.010040 442.315765 519.166626 221.875031 80926d
back_platform_0 1640.383789 420.668457 519.166626 221.875031 80926d
-4
+5
box_0 120.543991 -72.326294 112.500031 107.291695 9aa034
box_1 714.640747 516.840698 112.500031 107.291695 9aa034
box_3 977.140808 521.007324 112.500031 107.291695 9aa034
box_4 1263.946411 515.729614 112.500000 105.902771 9aa034
+box_0 1478.200684 515.248352 112.500000 105.902771 9aa034
0
0
static void kill_word(Edit_field *edit_field);
static void backward_kill_word(Edit_field *edit_field);
static void kill_to_end_of_line(Edit_field *edit_field);
+static void field_buffer_cut(Edit_field *edit_field);
+static void field_buffer_copy(Edit_field *edit_field);
+static void field_buffer_paste(Edit_field *edit_field);
static void handle_keydown(Edit_field *edit_field, const SDL_Event *event);
static void handle_keydown_alt(Edit_field *edit_field, const SDL_Event *event);
edit_field->buffer[++edit_field->buffer_size] = 0;
}
+static inline
+void edit_field_insert_string(Edit_field *edit_field, const char *text)
+{
+ size_t n = strlen(text);
+ for (size_t i = 0; i < n; ++i) {
+ edit_field_insert_char(edit_field, text[i]);
+ }
+}
+
// See: https://www.gnu.org/software/emacs/manual/html_node/emacs/Moving-Point.html
// For an explanation of the naming terminology for these helper methods
edit_field->buffer_size);
}
+static void field_buffer_cut(Edit_field *edit_field) {
+ // "C-w"
+ SDL_SetClipboardText(edit_field_as_text(edit_field));
+ edit_field_clean(edit_field);
+}
+
+static void field_buffer_copy(Edit_field *edit_field) {
+ // "M-w"
+ SDL_SetClipboardText(edit_field_as_text(edit_field));
+}
+
+static void field_buffer_paste(Edit_field *edit_field) {
+ // "C-y"
+ char *text = SDL_GetClipboardText();
+ edit_field_insert_string(edit_field, text);
+}
+
static void handle_keydown(Edit_field *edit_field, const SDL_Event *event)
{
switch (event->key.keysym.sym) {
case SDLK_d: {
kill_word(edit_field);
} break;
+
+ // TODO(#1219): edit_field should also support more conventional copy/paste/cut keys like Ctrl+C,Ctrl+V,Ctrl+X
+ // Emacs keybindings support is cool and all, but we also need to be more reflex inclusive.
+ // TODO(#1220): edit_field doesn't support selections for copy/cut operations
+ case SDLK_w: {
+ field_buffer_copy(edit_field);
+ } break;
}
}
case SDLK_k: {
kill_to_end_of_line(edit_field);
} break;
+
+ case SDLK_w: {
+ field_buffer_cut(edit_field);
+ } break;
+
+ case SDLK_y: {
+ field_buffer_paste(edit_field);
+ } break;
}
}