Skip to content

Commit

Permalink
Merge pull request #169 from curlpipe/dev
Browse files Browse the repository at this point in the history
0.6.7
  • Loading branch information
curlpipe authored Oct 17, 2024
2 parents 39ba0df + 4ba0b4b commit bb2192a
Show file tree
Hide file tree
Showing 40 changed files with 1,161 additions and 177 deletions.
26 changes: 12 additions & 14 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.
**What is the bug?**

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.
**What did you do to get the bug?**



**What behaviour were you expecting?**



**Screenshots (if applicable)**



**Desktop (please complete the following information):**
- OS: [e.g. iOS]
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**What feature would you like to see? (give details)**



**Are there any alternatives you have considered?**


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

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
10 changes: 0 additions & 10 deletions .todo.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
- [ ] General tweaks
- [ ] Group events together when committing for undo/redo
- [ ] Reconfiguring copy / paste to use osc52
- [ ] Safety update
- [ ] Document backups
- [ ] Panic busting & nicer panics / errors*
- [ ] Crossplatform support*
- [ ] Support for macOS
- [ ] Support for windows
Expand All @@ -13,12 +9,6 @@
- [ ] Actually render splits on the screen
- [ ] Split commands / API
- [ ] Vigorously test resizing / setting window size weirdly
- [ ] Plugin overhaul
- [ ] HTML editor*
- [ ] HTML tag pairs*
- [ ] Todo lists*
- [ ] Typing speed measurement
- [ ] Pomodoro timer
- [ ] Supporting infrastructure
- [ ] Configuration assistant
- [ ] Syntax highlighting assistant
Expand Down
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exclude = ["cactus"]

[package]
name = "ox"
version = "0.6.6"
version = "0.6.7"
edition = "2021"
authors = ["Curlpipe <[email protected]>"]
description = "A Rust powered text editor."
Expand Down
19 changes: 14 additions & 5 deletions config/.oxrc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ event_mapping = {
["pagedown"] = function()
editor:move_page_down()
end,
["ctrl_g"] = function()
local line = editor:prompt("Go to line")
editor:move_to(0, tonumber(line))
end,
-- Searching & Replacing
["ctrl_f"] = function()
editor:search()
Expand Down Expand Up @@ -180,7 +184,7 @@ commands = {
end
end,
["filetype"] = function(arguments)
local file_type_name = arguments[1]
local file_type_name = table.concat(arguments, " ")
editor:set_file_type(file_type_name)
end,
["reload"] = function(arguments)
Expand Down Expand Up @@ -228,6 +232,7 @@ line_numbers.padding_right = 1

-- Configure Mouse Behaviour --
terminal.mouse_enabled = true
terminal.scroll_amount = 1

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

-- Import plugins (must be at the bottom of this file)
load_plugin("pairs.lua")
Expand Down
64 changes: 50 additions & 14 deletions kaolinite/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use crate::event::{Error, Event, Result, Status, UndoMgmt};
use crate::map::{form_map, CharMap};
use crate::searching::{Match, Searcher};
use crate::utils::{
get_range, modeline, tab_boundaries_backward, tab_boundaries_forward, trim, width, Loc, Size,
get_absolute_path, get_range, modeline, tab_boundaries_backward, tab_boundaries_forward, trim,
width, Loc, Size,
};
use ropey::Rope;
use std::fs::File;
Expand Down Expand Up @@ -101,6 +102,7 @@ impl Document {
pub fn open<S: Into<String>>(size: Size, file_name: S) -> Result<Self> {
let file_name = file_name.into();
let file = Rope::from_reader(BufReader::new(File::open(&file_name)?))?;
let file_name = get_absolute_path(&file_name);
let mut this = Self {
info: DocumentInfo {
loaded_to: 0,
Expand All @@ -115,7 +117,7 @@ impl Document {
lines: vec![],
dbl_map: CharMap::default(),
tab_map: CharMap::default(),
file_name: Some(file_name),
file_name,
cursor: Cursor::default(),
offset: Loc::default(),
size,
Expand Down Expand Up @@ -622,14 +624,42 @@ impl Document {

/// Move up by 1 page
pub fn move_page_up(&mut self) {
self.move_to_y(self.cursor.loc.y.saturating_sub(self.size.h));
// Set x to 0
self.cursor.loc.x = 0;
self.char_ptr = 0;
self.old_cursor = 0;
// Calculate where to move the cursor
let new_cursor_y = self.cursor.loc.y.saturating_sub(self.size.h);
// Move to the new location and shift down offset proportionally
self.cursor.loc.y = new_cursor_y;
self.offset.y = self.offset.y.saturating_sub(self.size.h);
// Clean up
self.cancel_selection();
}

/// Move down by 1 page
pub fn move_page_down(&mut self) {
self.move_to_y(self.cursor.loc.y + self.size.h);
// Set x to 0
self.cursor.loc.x = 0;
self.char_ptr = 0;
self.old_cursor = 0;
// Calculate where to move the cursor
let new_cursor_y = self.cursor.loc.y + self.size.h;
if new_cursor_y <= self.len_lines() {
// Cursor is in range, move to the new location and shift down offset proportionally
self.cursor.loc.y = new_cursor_y;
self.offset.y += self.size.h;
} else if self.len_lines() < self.offset.y + self.size.h {
// End line is in view, no need to move offset
self.cursor.loc.y = self.len_lines().saturating_sub(1);
} else {
// Cursor would be out of range (adjust to bottom of document)
self.cursor.loc.y = self.len_lines().saturating_sub(1);
self.offset.y = self.len_lines().saturating_sub(self.size.h);
}
// Clean up
self.load_to(self.offset.y + self.size.h);
self.cancel_selection();
}

/// Moves to the previous word in the document
Expand All @@ -638,17 +668,23 @@ impl Document {
if x == 0 && y != 0 {
return Status::StartOfLine;
}
let re = format!("(\t| {{{}}}|^|\\W| )", self.tab_width);
if let Some(mut mtch) = self.prev_match(&re) {
let len = mtch.text.chars().count();
let same = mtch.loc.x + len == x;
if !same {
mtch.loc.x += len;
let re = format!("(\t| {{{}}}|^|\\W|$| )", self.tab_width);
let mut searcher = Searcher::new(&re);
let line = self
.line(y)
.unwrap_or_default()
.chars()
.take(x)
.collect::<String>();
let mut matches = searcher.rfinds(&line);
if let Some(mtch) = matches.first() {
if mtch.loc.x == x {
matches.remove(0);
}
}
if let Some(mtch) = matches.first_mut() {
mtch.loc.y = self.loc().y;
self.move_to(&mtch.loc);
if same && self.loc().x != 0 {
return self.move_prev_word();
}
}
self.old_cursor = self.loc().x;
Status::None
Expand Down Expand Up @@ -1084,7 +1120,7 @@ impl Document {
x: self.cursor.loc.x.saturating_sub(self.offset.x),
y: self.cursor.loc.y.saturating_sub(self.offset.y),
};
if result.x > self.size.w || result.y > self.size.h {
if result.x > self.size.w || result.y >= self.size.h {
return None;
}
Some(result)
Expand Down
Loading

0 comments on commit bb2192a

Please sign in to comment.