diff --git a/4coder_API.html b/4coder_API.html index 8b2c90aa..963acd74 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -1139,18 +1139,6 @@ the range [1,16].
cmdid_open_debug opens the debug information viewer mode.
-
cmdid_open_panel_vsplit
-
cmdid_open_panel_vsplit splits the current panel into two with a vertical divider.
-
-
-
cmdid_open_panel_hsplit
-
cmdid_open_panel_hsplit splits the current panel into two with a horizontal divider.
-
-
-
cmdid_close_panel
-
cmdid_close_panel closes the active panel.
-
-
cmdid_count
diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index e5df52ac..2bd3122d 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -357,7 +357,7 @@ default_keys(Bind_Helper *context){ bind(context, 'g', MDFR_CTRL, goto_line); bind(context, 'h', MDFR_CTRL, cmdid_history_backward); bind(context, 'H', MDFR_CTRL, cmdid_history_forward); - bind(context, 'j', MDFR_CTRL, cmdid_to_lowercase); + bind(context, 'j', MDFR_CTRL, to_lowercase); bind(context, 'K', MDFR_CTRL, cmdid_kill_buffer); bind(context, 'l', MDFR_CTRL, toggle_line_wrap); bind(context, 'm', MDFR_CTRL, cursor_mark_swap); @@ -366,7 +366,7 @@ default_keys(Bind_Helper *context){ bind(context, 'r', MDFR_CTRL, reverse_search); bind(context, 's', MDFR_ALT, show_scrollbar); bind(context, 's', MDFR_CTRL, cmdid_save); - bind(context, 'u', MDFR_CTRL, cmdid_to_uppercase); + bind(context, 'u', MDFR_CTRL, to_uppercase); bind(context, 'U', MDFR_CTRL, rewrite_as_single_caps); bind(context, 'v', MDFR_CTRL, paste); bind(context, 'V', MDFR_CTRL, paste_next); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 666f3058..29738c9a 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -394,6 +394,44 @@ CUSTOM_COMMAND_SIG(paste_next){ } } +// +// Fancy Editing +// + +CUSTOM_COMMAND_SIG(to_uppercase){ + View_Summary view = app->get_active_view(app, AccessOpen); + Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen); + + Range range = get_range(&view); + int size = range.max - range.min; + if (size <= app->memory_size){ + char *mem = (char*)app->memory; + + app->buffer_read_range(app, &buffer, range.min, range.max, mem); + for (int i = 0; i < size; ++i){ + mem[i] = char_to_upper(mem[i]); + } + app->buffer_replace_range(app, &buffer, range.min, range.max, mem, size); + } +} + +CUSTOM_COMMAND_SIG(to_lowercase){ + View_Summary view = app->get_active_view(app, AccessOpen); + Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen); + + Range range = get_range(&view); + int size = range.max - range.min; + if (size <= app->memory_size){ + char *mem = (char*)app->memory; + + app->buffer_read_range(app, &buffer, range.min, range.max, mem); + for (int i = 0; i < size; ++i){ + mem[i] = char_to_lower(mem[i]); + } + app->buffer_replace_range(app, &buffer, range.min, range.max, mem, size); + } +} + // // Various Forms of Seek // diff --git a/4coder_types.h b/4coder_types.h index 2aa85ca0..e9a23ce8 100644 --- a/4coder_types.h +++ b/4coder_types.h @@ -67,11 +67,6 @@ ENUM(uint64_t, Command_ID){ /* DOC(cmdid_history_forward unperforms the previous cmdid_history_backward step if possib.e) */ cmdid_history_forward, - /* DOC(cmdid_to_uppercase makes all the alphabetic characters in the cursor/mark range uppercase.) */ - cmdid_to_uppercase, - /* DOC(cmdid_to_uppercase makes all the alphabetic characters in the cursor/mark range lowercase.) */ - cmdid_to_lowercase, - /* DOC(cmdid_clean_all_lines deletes extra whitespace out the currently active buffer.) */ cmdid_clean_all_lines, @@ -101,15 +96,6 @@ ENUM(uint64_t, Command_ID){ /* DOC(cmdid_open_debug opens the debug information viewer mode.) */ cmdid_open_debug, -#if 0 - /* DOC(cmdid_open_panel_vsplit splits the current panel into two with a vertical divider.) */ - cmdid_open_panel_vsplit, - /* DOC(cmdid_open_panel_hsplit splits the current panel into two with a horizontal divider.) */ - cmdid_open_panel_hsplit, - /* DOC(cmdid_close_panel closes the active panel.) */ - cmdid_close_panel, -#endif - // count cmdid_count }; diff --git a/4ed.cpp b/4ed.cpp index c2fe5976..6c618805 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -1028,15 +1028,13 @@ setup_command_table(){ SET(interactive_new); SET(interactive_open); - SET(reopen); - SET(save); - SET(save_as); SET(interactive_switch_buffer); SET(interactive_kill_buffer); + SET(save_as); + + SET(reopen); + SET(save); SET(kill_buffer); - - SET(to_uppercase); - SET(to_lowercase); SET(clean_all_lines);