Skip to content

Commit

Permalink
Merge pull request #185 from curlpipe/0.7.3
Browse files Browse the repository at this point in the history
0.7.3
  • Loading branch information
curlpipe authored Dec 1, 2024
2 parents 6bc2a50 + 40a7c4a commit 8aa69a6
Show file tree
Hide file tree
Showing 28 changed files with 633 additions and 183 deletions.
13 changes: 0 additions & 13 deletions .todo.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
- [ ] Safety update
- [ ] Document backups
- [ ] Crossplatform support*
- [ ] Support for macOS
- [ ] Support for windows
- [ ] Splitting*
- [ ] Move towards tree structure of document groups
- [ ] Clean API from in-house Tree struct
- [ ] Actually render splits on the screen
- [ ] Split commands / API
- [ ] Vigorously test resizing / setting window size weirdly
- [ ] Supporting infrastructure
- [ ] Configuration assistant
- [ ] Syntax highlighting assistant
- [ ] Discord rich presence
- [ ] File tree*
- [ ] Implement file tree
- [ ] Code prettifier
Expand Down
43 changes: 26 additions & 17 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [

[package]
name = "ox"
version = "0.7.2"
version = "0.7.3"
edition = "2021"
authors = ["Curlpipe <[email protected]>"]
description = "A simple but flexible text editor."
Expand Down Expand Up @@ -40,4 +40,4 @@ kaolinite = { path = "./kaolinite" }
mlua = { version = "0.10", features = ["lua54", "vendored"] }
error_set = "0.7"
shellexpand = "3.1.0"
synoptic = "2.2.7"
synoptic = "2.2.9"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ It works best on linux, but macOS and Windows are also supported.

### Lightweight and Efficient

- :feather: Ox is lightweight, with the precompiled binary taking up roughly 5mb in storage space.
- :feather: Ox is lightweight, with the precompiled binary taking up a few megabytes in storage space.
- :knot: It uses a `rope` data structure which allows incremental editing, file reading and file writing, which will speed up performance, particularly on huge files.
- :crab: It was built in Rust, which is a quick lower-level language that has a strong reputation in the performance department.

Expand Down
4 changes: 4 additions & 0 deletions config/.oxrc
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ colors.tab_inactive_bg = {59, 59, 84}
colors.tab_active_fg = {255, 255, 255}
colors.tab_active_bg = {41, 41, 61}

colors.split_bg = {41, 41, 61}
colors.split_fg = {59, 59, 84}

colors.info_fg = {99, 162, 255}
colors.info_bg = {41, 41, 61}
colors.warning_fg = {255, 182, 99}
Expand All @@ -409,6 +412,7 @@ terminal.scroll_amount = 4

-- Configure Tab Line --
tab_line.enabled = true
tab_line.separators = true
tab_line.format = " {file_name}{modified} "

-- Configure Status Line --
Expand Down
2 changes: 1 addition & 1 deletion kaolinite/.todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Kibi rival
- [X] Test suite
Code Editor
- [X] Syntax highlighting (2 weeks) (+20)
- [ ] Build Ox 0.3
- [X] Build Ox 0.3
- [X] Undo & Redo
- [X] Command line interface
- [X] Multiple buffers
Expand Down
6 changes: 3 additions & 3 deletions kaolinite/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ impl Event {

/// Get the location of an event
#[must_use]
pub fn loc(self) -> Loc {
pub fn loc(&self) -> Loc {
match self {
Event::Insert(loc, _)
| Event::Delete(loc, _)
| Event::SplitDown(loc)
| Event::SpliceUp(loc) => loc,
Event::InsertLine(loc, _) | Event::DeleteLine(loc, _) => Loc { x: 0, y: loc },
| Event::SpliceUp(loc) => *loc,
Event::InsertLine(loc, _) | Event::DeleteLine(loc, _) => Loc { x: 0, y: *loc },
}
}

Expand Down
11 changes: 10 additions & 1 deletion kaolinite/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// utils.rs - utilities to assist in editing and keep code in document.rs readable
use std::ops::{Bound, RangeBounds};
use std::path::Path;
use unicode_width::UnicodeWidthStr;
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};

/// Utility for easily forming a regular expression from a string
#[macro_export]
Expand Down Expand Up @@ -100,6 +100,15 @@ pub fn width(st: &str, tab_width: usize) -> usize {
(st.width() + tabs * tab_width).saturating_sub(tabs)
}

/// Utility function to determine the width of a character, with variable tab width
#[must_use]
pub fn width_char(ch: &char, tab_width: usize) -> usize {
match ch {
'\t' => tab_width,
_ => ch.width().unwrap_or(0),
}
}

/// Utility function to take a line and determine where spaces should be treated as tabs (forwards)
#[must_use]
pub fn tab_boundaries_forward(line: &str, tab_width: usize) -> Vec<usize> {
Expand Down
66 changes: 40 additions & 26 deletions plugins/git.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
Git v0.4
Git v0.5
A plug-in for git integration that provides features to:
- Choose which files to add to a commit
Expand All @@ -12,8 +12,10 @@ A plug-in for git integration that provides features to:

git = {
status = {},
branch = "",
icons = (git or { icons = false }).icons,
has_git = shell:output("git --version"):find("git version"),
last_update = nil,
}

function git:ready()
Expand All @@ -26,30 +28,36 @@ function git:repo_path()
end

function git:refresh_status()
local repo_path = self:repo_path()
local status_output = shell:output("git status --porcelain")
local status = {}
for line in status_output:gmatch("[^\r\n]+") do
local staged_status = line:sub(1, 1)
local unstaged_status = line:sub(2, 2)
local file_name = repo_path .. "/" .. line:sub(4)
local staged
local modified
if self.icons then
staged = "󰸩 "
modified = "󱇨 "
else
staged = "S"
modified = "M"
end
-- M = modified, S = staged
if staged_status ~= " " and staged_status ~= "?" then
status[file_name] = staged
elseif unstaged_status ~= " " or unstaged_status == "?" then
status[file_name] = modified
local duration_since_update = os.time(os.date("*t")) - os.time(self.last_update)
-- Only do a refresh every 10 seconds maximum
if self.last_update == nil or duration_since_update > 10 then
self.branch = shell:output("git rev-parse --abbrev-ref HEAD")
local repo_path = self:repo_path()
local status_output = shell:output("git status --porcelain")
local status = {}
for line in status_output:gmatch("[^\r\n]+") do
local staged_status = line:sub(1, 1)
local unstaged_status = line:sub(2, 2)
local file_name = repo_path .. "/" .. line:sub(4)
local staged
local modified
if self.icons then
staged = "󰸩 "
modified = "󱇨 "
else
staged = "S"
modified = "M"
end
-- M = modified, S = staged
if staged_status ~= " " and staged_status ~= "?" then
status[file_name] = staged
elseif unstaged_status ~= " " or unstaged_status == "?" then
status[file_name] = modified
end
end
self.status = status
self.last_update = os.date("*t")
end
self.status = status
end

function git:get_stats()
Expand Down Expand Up @@ -88,11 +96,10 @@ end

function git_branch()
git:refresh_status()
local branch = shell:output("git rev-parse --abbrev-ref HEAD")
if branch == "" or branch:match("fatal") then
if git.branch == "" or git.branch:match("fatal") then
return "N/A"
else
return branch:gsub("[\r\n]+", "")
return git.branch:gsub("[\r\n]+", "")
end
end

Expand All @@ -119,6 +126,12 @@ end
-- Initial status grab
after(0, "git_init")

-- When the user saves a document, force a refresh
event_mapping["ctrl_s"] = function()
git.last_update = nil
git:refresh_status()
end

-- Export the git command
commands["git"] = function(args)
-- Check if git is installed
Expand Down Expand Up @@ -194,6 +207,7 @@ commands["git"] = function(args)
end
end
-- Refresh state after a git command
git.last_update = nil
git:refresh_status()
end
end
12 changes: 10 additions & 2 deletions plugins/pairs.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
Bracket Pairs v0.5
Bracket Pairs v0.6
Automatically insert and delete brackets and quotes where appropriate
Also helps when you want to pad out brackets and quotes with whitespace
Expand All @@ -19,8 +19,16 @@ autopairs.just_paired = { x = nil, y = nil }

-- Determine whether we are currently inside a pair
function autopairs:in_pair()
local first = editor:get_character_at(editor.cursor.x - 1, editor.cursor.y)
-- Get first candidate for a pair
local first
if editor.cursor.x == 0 then
first = ""
else
first = editor:get_character_at(editor.cursor.x - 1, editor.cursor.y)
end
-- Get second candidate for a pair
local second = editor:get_character_at(editor.cursor.x, editor.cursor.y)
-- See if there are any matches
local potential_pair = first .. second
for _, v in ipairs(autopairs.pairings) do
if v == potential_pair then
Expand Down
2 changes: 1 addition & 1 deletion plugins/pomodoro.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Pomodoro Timer v0.1
A simple timer to help you space out your work with breaks
This technique is also said to help increase memory retention during study
--]]
]]--

-- Define our pomodoro state
pomodoro = {
Expand Down
Loading

0 comments on commit 8aa69a6

Please sign in to comment.