Skip to content

Commit bb2192a

Browse files
authored
Merge pull request #169 from curlpipe/dev
0.6.7
2 parents 39ba0df + 4ba0b4b commit bb2192a

40 files changed

+1161
-177
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,19 @@ assignees: ''
77

88
---
99

10-
**Describe the bug**
11-
A clear and concise description of what the bug is.
10+
**What is the bug?**
1211

13-
**To Reproduce**
14-
Steps to reproduce the behavior:
15-
1. Go to '...'
16-
2. Click on '....'
17-
3. Scroll down to '....'
18-
4. See error
1912

20-
**Expected behavior**
21-
A clear and concise description of what you expected to happen.
2213

23-
**Screenshots**
24-
If applicable, add screenshots to help explain your problem.
14+
**What did you do to get the bug?**
15+
16+
17+
18+
**What behaviour were you expecting?**
19+
20+
21+
22+
**Screenshots (if applicable)**
23+
24+
2525

26-
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ assignees: ''
77

88
---
99

10-
**Is your feature request related to a problem? Please describe.**
11-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
10+
**What feature would you like to see? (give details)**
11+
12+
13+
14+
**Are there any alternatives you have considered?**
15+
1216

13-
**Describe the solution you'd like**
14-
A clear and concise description of what you want to happen.
1517

16-
**Describe alternatives you've considered**
17-
A clear and concise description of any alternative solutions or features you've considered.

.todo.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
- [ ] General tweaks
2-
- [ ] Group events together when committing for undo/redo
3-
- [ ] Reconfiguring copy / paste to use osc52
41
- [ ] Safety update
52
- [ ] Document backups
6-
- [ ] Panic busting & nicer panics / errors*
73
- [ ] Crossplatform support*
84
- [ ] Support for macOS
95
- [ ] Support for windows
@@ -13,12 +9,6 @@
139
- [ ] Actually render splits on the screen
1410
- [ ] Split commands / API
1511
- [ ] Vigorously test resizing / setting window size weirdly
16-
- [ ] Plugin overhaul
17-
- [ ] HTML editor*
18-
- [ ] HTML tag pairs*
19-
- [ ] Todo lists*
20-
- [ ] Typing speed measurement
21-
- [ ] Pomodoro timer
2212
- [ ] Supporting infrastructure
2313
- [ ] Configuration assistant
2414
- [ ] Syntax highlighting assistant

Cargo.lock

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exclude = ["cactus"]
77

88
[package]
99
name = "ox"
10-
version = "0.6.6"
10+
version = "0.6.7"
1111
edition = "2021"
1212
authors = ["Curlpipe <[email protected]>"]
1313
description = "A Rust powered text editor."

config/.oxrc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ event_mapping = {
4949
["pagedown"] = function()
5050
editor:move_page_down()
5151
end,
52+
["ctrl_g"] = function()
53+
local line = editor:prompt("Go to line")
54+
editor:move_to(0, tonumber(line))
55+
end,
5256
-- Searching & Replacing
5357
["ctrl_f"] = function()
5458
editor:search()
@@ -180,7 +184,7 @@ commands = {
180184
end
181185
end,
182186
["filetype"] = function(arguments)
183-
local file_type_name = arguments[1]
187+
local file_type_name = table.concat(arguments, " ")
184188
editor:set_file_type(file_type_name)
185189
end,
186190
["reload"] = function(arguments)
@@ -228,6 +232,7 @@ line_numbers.padding_right = 1
228232

229233
-- Configure Mouse Behaviour --
230234
terminal.mouse_enabled = true
235+
terminal.scroll_amount = 1
231236

232237
-- Configure Tab Line --
233238
tab_line.enabled = true
@@ -276,6 +281,7 @@ Ctrl + F: Find
276281
Ctrl + R: Replace
277282
Ctrl + W: Delete Word
278283
Ctrl + D: Delete Line
284+
Ctrl + G: Go to a line
279285
Alt + Up: Move line up
280286
Alt + Down: Move line down
281287
Ctrl + K: Command Line
@@ -306,10 +312,13 @@ syntax:set("heading", {47, 141, 252}) -- Headings in various markup languages e.
306312
syntax:set("link", {223, 52, 249}) -- Links in various markup languages e.g. URLs
307313
syntax:set("key", {223, 52, 249}) -- Keys in various markup languages
308314
syntax:set("quote", {113, 113, 169}) -- Quotes in various markup languages e.g. > in markdown
309-
syntax:set("bold", {40, 198, 232}) -- Quotes in various markup languages e.g. * in markdown
310-
syntax:set("italic", {40, 198, 232}) -- Quotes in various markup languages e.g. _ in markdown
311-
syntax:set("block", {40, 198, 232}) -- Quotes in various markup languages e.g. _ in markdown
312-
syntax:set("list", {86, 217, 178}) -- Quotes in various markup languages e.g. _ in markdown
315+
syntax:set("bold", {40, 198, 232}) -- Bold text in various markup languages e.g. * in markdown
316+
syntax:set("italic", {40, 198, 232}) -- Italic text in various markup languages e.g. ** in markdown
317+
syntax:set("block", {40, 198, 232}) -- Code blocks in various markup languages e.g. `````` in markdown
318+
syntax:set("image", {40, 198, 232}) -- Images in various markup languages e.g. ![]() in markdown
319+
syntax:set("list", {86, 217, 178}) -- Lists in various markup languages e.g. - in markdown
320+
syntax:set("insertion", {39, 222, 145}) -- Images in various markup languages e.g. ![]() in markdown
321+
syntax:set("deletion", {255, 100, 100}) -- Lists in various markup languages e.g. - in markdown
313322

314323
-- Import plugins (must be at the bottom of this file)
315324
load_plugin("pairs.lua")

kaolinite/src/document.rs

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::event::{Error, Event, Result, Status, UndoMgmt};
33
use crate::map::{form_map, CharMap};
44
use crate::searching::{Match, Searcher};
55
use crate::utils::{
6-
get_range, modeline, tab_boundaries_backward, tab_boundaries_forward, trim, width, Loc, Size,
6+
get_absolute_path, get_range, modeline, tab_boundaries_backward, tab_boundaries_forward, trim,
7+
width, Loc, Size,
78
};
89
use ropey::Rope;
910
use std::fs::File;
@@ -101,6 +102,7 @@ impl Document {
101102
pub fn open<S: Into<String>>(size: Size, file_name: S) -> Result<Self> {
102103
let file_name = file_name.into();
103104
let file = Rope::from_reader(BufReader::new(File::open(&file_name)?))?;
105+
let file_name = get_absolute_path(&file_name);
104106
let mut this = Self {
105107
info: DocumentInfo {
106108
loaded_to: 0,
@@ -115,7 +117,7 @@ impl Document {
115117
lines: vec![],
116118
dbl_map: CharMap::default(),
117119
tab_map: CharMap::default(),
118-
file_name: Some(file_name),
120+
file_name,
119121
cursor: Cursor::default(),
120122
offset: Loc::default(),
121123
size,
@@ -622,14 +624,42 @@ impl Document {
622624

623625
/// Move up by 1 page
624626
pub fn move_page_up(&mut self) {
625-
self.move_to_y(self.cursor.loc.y.saturating_sub(self.size.h));
627+
// Set x to 0
628+
self.cursor.loc.x = 0;
629+
self.char_ptr = 0;
626630
self.old_cursor = 0;
631+
// Calculate where to move the cursor
632+
let new_cursor_y = self.cursor.loc.y.saturating_sub(self.size.h);
633+
// Move to the new location and shift down offset proportionally
634+
self.cursor.loc.y = new_cursor_y;
635+
self.offset.y = self.offset.y.saturating_sub(self.size.h);
636+
// Clean up
637+
self.cancel_selection();
627638
}
628639

629640
/// Move down by 1 page
630641
pub fn move_page_down(&mut self) {
631-
self.move_to_y(self.cursor.loc.y + self.size.h);
642+
// Set x to 0
643+
self.cursor.loc.x = 0;
644+
self.char_ptr = 0;
632645
self.old_cursor = 0;
646+
// Calculate where to move the cursor
647+
let new_cursor_y = self.cursor.loc.y + self.size.h;
648+
if new_cursor_y <= self.len_lines() {
649+
// Cursor is in range, move to the new location and shift down offset proportionally
650+
self.cursor.loc.y = new_cursor_y;
651+
self.offset.y += self.size.h;
652+
} else if self.len_lines() < self.offset.y + self.size.h {
653+
// End line is in view, no need to move offset
654+
self.cursor.loc.y = self.len_lines().saturating_sub(1);
655+
} else {
656+
// Cursor would be out of range (adjust to bottom of document)
657+
self.cursor.loc.y = self.len_lines().saturating_sub(1);
658+
self.offset.y = self.len_lines().saturating_sub(self.size.h);
659+
}
660+
// Clean up
661+
self.load_to(self.offset.y + self.size.h);
662+
self.cancel_selection();
633663
}
634664

635665
/// Moves to the previous word in the document
@@ -638,17 +668,23 @@ impl Document {
638668
if x == 0 && y != 0 {
639669
return Status::StartOfLine;
640670
}
641-
let re = format!("(\t| {{{}}}|^|\\W| )", self.tab_width);
642-
if let Some(mut mtch) = self.prev_match(&re) {
643-
let len = mtch.text.chars().count();
644-
let same = mtch.loc.x + len == x;
645-
if !same {
646-
mtch.loc.x += len;
671+
let re = format!("(\t| {{{}}}|^|\\W|$| )", self.tab_width);
672+
let mut searcher = Searcher::new(&re);
673+
let line = self
674+
.line(y)
675+
.unwrap_or_default()
676+
.chars()
677+
.take(x)
678+
.collect::<String>();
679+
let mut matches = searcher.rfinds(&line);
680+
if let Some(mtch) = matches.first() {
681+
if mtch.loc.x == x {
682+
matches.remove(0);
647683
}
684+
}
685+
if let Some(mtch) = matches.first_mut() {
686+
mtch.loc.y = self.loc().y;
648687
self.move_to(&mtch.loc);
649-
if same && self.loc().x != 0 {
650-
return self.move_prev_word();
651-
}
652688
}
653689
self.old_cursor = self.loc().x;
654690
Status::None
@@ -1084,7 +1120,7 @@ impl Document {
10841120
x: self.cursor.loc.x.saturating_sub(self.offset.x),
10851121
y: self.cursor.loc.y.saturating_sub(self.offset.y),
10861122
};
1087-
if result.x > self.size.w || result.y > self.size.h {
1123+
if result.x > self.size.w || result.y >= self.size.h {
10881124
return None;
10891125
}
10901126
Some(result)

0 commit comments

Comments
 (0)