summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-02 18:05:02 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-02 18:05:02 -0500
commit189bbdf3e1d5285fc0508d1a190036d6f4295558 (patch)
treef7316b668b75085a5afdb880fe6712c4310e512f /main.c
parent496c8aeb321be70292837d15a14a0dfb0f17e33c (diff)
double/triple click to select word/line
Diffstat (limited to 'main.c')
-rw-r--r--main.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/main.c b/main.c
index eca095b..9ece8ac 100644
--- a/main.c
+++ b/main.c
@@ -1,3 +1,7 @@
+// @TODO:
+// - select all (:select-all)
+// - blinking cursor (cursor-blink-time)
+// - text size (text-size, :increase-text-size, :decrease-text-size)
#include "base.h"
no_warn_start
#if _WIN32
@@ -13,9 +17,6 @@ no_warn_end
#include "command.h"
#include "util.c"
#include "colors.c"
-// @TODO:
-// - blinking cursor (cursor-blink-time)
-// - text size
typedef struct {
u32 colors[COLOR_COUNT];
u8 tab_width;
@@ -142,10 +143,20 @@ int main(void) {
case SDL_BUTTON_LEFT: {
BufferPos pos = {0};
if (buffer_pixels_to_pos(buffer, V2((float)event.button.x, (float)event.button.y), &pos)) {
- if (key_modifier == KEY_MODIFIER_SHIFT)
+ if (key_modifier == KEY_MODIFIER_SHIFT) {
buffer_select_to_pos(buffer, pos);
- else if (key_modifier == 0)
+ } else if (key_modifier == 0) {
buffer_cursor_move_to_pos(buffer, pos);
+ switch ((event.button.clicks - 1) % 3) {
+ case 0: break; // single-click
+ case 1: // double-click: select word
+ buffer_select_word(buffer);
+ break;
+ case 2: // triple-click: select line
+ buffer_select_line(buffer);
+ break;
+ }
+ }
}
} break;
}