Improve double click
This commit is contained in:
@@ -102,6 +102,11 @@ bool InBounds(const Buffer &buffer, Int pos) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool InBounds(Range range, Int pos) {
|
||||
bool result = pos >= range.min && pos < range.max;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AreEqual(Range a, Range b) {
|
||||
bool result = a.min == b.min && a.max == b.max;
|
||||
return result;
|
||||
|
||||
@@ -50,7 +50,7 @@ bool IsDoubleClick() {
|
||||
double diff = time - last_click_time;
|
||||
last_click_time = time;
|
||||
// @todo: don't do this manually, use windows
|
||||
if (diff >= 0.05 && diff <= 0.25) {
|
||||
if (diff >= 0.05 && diff <= 0.3) {
|
||||
last_click_time = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,10 @@ Font MenuFont;
|
||||
#include "view_draw.cpp"
|
||||
|
||||
/*
|
||||
- Ctrl + D - create new cursor at next occurence of word
|
||||
- Colored strings
|
||||
|
||||
- move off raylib
|
||||
- line endings
|
||||
- file dock on left side
|
||||
- multiple windows
|
||||
- multiple views per window
|
||||
|
||||
@@ -332,15 +332,18 @@ void HandleKeybindings(View *_view) {
|
||||
|
||||
if (mouse_in_view && IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
||||
if (IsDoubleClick()) {
|
||||
Caret *c = GetLast(view.carets);
|
||||
if (InBounds({c->range.min - 1, c->range.max + 1}, p)) {
|
||||
c->range = EncloseWord(buf, p);
|
||||
view.selection_anchor = c->range;
|
||||
}
|
||||
} else {
|
||||
if (!IsKeyDown(KEY_LEFT_CONTROL)) {
|
||||
view.carets.len = 0;
|
||||
}
|
||||
Add(&view.carets, MakeCaret(p, p));
|
||||
view.selection_anchor = GetLast(view.carets)->range;
|
||||
if (IsDoubleClick()) {
|
||||
Caret *c = GetLast(view.carets);
|
||||
c->range = EncloseWord(buf, p);
|
||||
view.selection_anchor = c->range;
|
||||
}
|
||||
|
||||
MergeCarets(&view.carets);
|
||||
|
||||
Reference in New Issue
Block a user