Skip to content

Commit

Permalink
Modify findAll
Browse files Browse the repository at this point in the history
  • Loading branch information
naotsugu committed Feb 9, 2025
1 parent e6a515f commit df21caa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
23 changes: 14 additions & 9 deletions docs/keyboard-shortcut.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Keyboard Shortcut

| shortcut | description |
|--------------|----------------------------------|
| `Ctrl` + `` | Half-page up |
| `Ctrl` + `` | Half-page down |
| `Ctrl` + `` | Move the caret to the right word |
| `Ctrl` + `` | Move the caret to the left word |
| `Ctrl` + `p` | Open the command pallet |
| `Ctrl` + `l` | Toggle line wrap |
| `Ctrl` + `s` | Save current file |
| shortcut | description |
|------------------------|---------------------------------------|
| `Ctrl` + `` | Half-page up |
| `Ctrl` + `` | Half-page down |
| `Ctrl` + `` | Move the caret to the right word |
| `Ctrl` + `` | Move the caret to the left word |
| `Ctrl` + `p` | Open the command pallet |
| `Ctrl` + `l` | Toggle line wrap |
| `Ctrl` + `s` | Save current file |
| `Ctrl` + `Shift` + 1s` | Save as |
| `F3` | Find next(with previous criteria) |
| `Ctrl` + `F3` | Find previous(with previous criteria) |
| `Ctrl` + `+` | Zoom in |
| `Ctrl` + `-` | Zoom out |
Original file line number Diff line number Diff line change
Expand Up @@ -619,41 +619,42 @@ public void imeComposed(String text) {
}

void findAll(FindSpec spec) {
for (Point point : content.findAll(spec)) {
decorate.addHighlights(point.row(), new StyleSpan(
new Style.BgColor("#FDD835"),
point.col(),
spec.pattern().length())
);
if (!spec.isEmpty()) {
findSpec = spec;
}
Caret c = carets.getFirst();
content.findAll(findSpec).forEach(p -> {
if (!c.isMarked()) {
c.markTo(p.row(), p.col(), p.row(), p.col() + p.len());
scrollToCaretY(screenLayout.screenLineSize() / 2);
}
decorate.addHighlights(p.row(), new StyleSpan(new Style.BgColor("#FDD835"), p.col(), p.len()));
});
}

void findNext(FindSpec spec) {
if (spec.isEmpty()) {
spec = findSpec;
} else {
if (!spec.isEmpty()) {
findSpec = spec;
}
Caret c = carets.unique();
var point = c.isMarked() ? Collections.max(List.of(c.point(), c.markedPoint())) : c.point();
content.findNext(point, spec).ifPresent(p ->
content.findNext(point, findSpec).ifPresent(p ->
c.markTo(p.row(), p.col(), p.row(), p.col() + p.len()));
scrollToCaretY(screenLayout.screenLineSize() / 2);
}

void findPrev(FindSpec spec) {
if (spec.isEmpty()) {
spec = findSpec;
} else {
if (!spec.isEmpty()) {
findSpec = spec;
}
Caret c = carets.unique();
var point = c.isMarked() ? Collections.min(List.of(c.point(), c.markedPoint())) : c.point();
content.findPrev(point, spec).ifPresent(p ->
content.findPrev(point, findSpec).ifPresent(p ->
c.markTo(p.row(), p.col(), p.row(), p.col() + p.len()));
scrollToCaretY(screenLayout.screenLineSize() / 2);
}


@Override
public Session getSession() {
return new Session.SessionRecord(
Expand Down

0 comments on commit df21caa

Please sign in to comment.