Skip to content

Commit

Permalink
select word on double click
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobhellermann committed Aug 26, 2024
1 parent 0f2cfa3 commit 73e8999
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Studio/CelesteStudio/Editing/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2699,6 +2699,32 @@ protected override void OnMouseMove(MouseEventArgs e) {
base.OnMouseMove(e);
}

protected override void OnMouseDoubleClick(MouseEventArgs e) {
var position = Document.Caret;
string line = Document.Lines[position.Row];

int startIdx = position.Col;
int endIdx = position.Col;
while (startIdx > 0 && ShouldExpand(line[startIdx-1])) {
startIdx--;
}
while (endIdx < line.Length && ShouldExpand(line[endIdx])) {
endIdx++;
}

Document.Selection.Start = position with { Col = startIdx };
Document.Selection.End = position with { Col = endIdx };

e.Handled = true;
Recalc();
return;

bool ShouldExpand(char c) {
return !char.IsWhiteSpace(c) && (!char.IsPunctuation(c) || c is '*' or '_');
}
}


protected override void OnMouseWheel(MouseEventArgs e) {
// Adjust frame count
if (e.Modifiers.HasFlag(Keys.Shift)) {
Expand Down

0 comments on commit 73e8999

Please sign in to comment.