Update to 0.0.4 #1

Merged
candle merged 5 commits from master into release 2025-07-15 15:28:36 +00:00
4 changed files with 107 additions and 2 deletions
Showing only changes of commit 3918bbff93 - Show all commits

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.c*
Cargo.lock Cargo.lock
/target /target
perf.* perf.*

25
LICENSE-MIT Normal file
View File

@ -0,0 +1,25 @@
Copyright (c) Filip Bicki <candle@lampnet.io>
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

75
README.md Normal file
View File

@ -0,0 +1,75 @@
# ced - candle's Editor
There is a disturbing lack of simple GUI text editors available on Linux natively. The world of TUI editors is flourishing, but regular people don't 'yank to system register' when they want to move text from one file to another. In the world of GUI text editors you have a few options, all with their own caveats:\
`gedit` -> Good for the GNOME Desktop, but uses GTK-4.0 so it stands out anywhere else.\
`Kate` -> If you're not on KDE already, it comes with tons of overhead (52 packages on Arch Linux for an application to write text).\
`Emacs` -> Requires a degree in understanding its documentation.
(c)andle's (Ed)itor aims to be a single ~~hopefully small~~ binary for that one purpose.
## Features
* Sane text editing with standard keybindings (`Ctrl+A`, `Ctrl+C`, etc.).
* Opens with a blank slate for quick typing, remember Notepad?
* Separate UI zoom that doesn't affect font size (`Ctrl+Shift` + `+`/`-`).
* Ricers rejoice, your `pywal` colors will be used!
* Weirdly smooth typing experience.
## Build and Install
##### Requirements
`git`, `rust`/`rustup`/`cargo`
##### Arch Linux
`sudo pacman -S git rust`
##### Ubuntu/Debian
`sudo apt install git rust`
#### Install
```bash
git clone https://code.lampnet.io/candle/ced
cd ced && cargo build --release
sudo mv target/release/ced /usr/local/bin/
sudo install -Dm644 ced.desktop /usr/share/applications/ced.desktop
```
`ced` should now appear as 'Text Editor' in your application launcher. You can remove the cloned directory at this point.
## Configuration
`ced` will look for, and create if needed, a configuration file at: `$XDG_CONFIG_HOME/ced/config.toml`.
Here is an example `config.toml`:
```toml
auto_hide_toolbar = false
show_line_numbers = false
word_wrap = false
theme = "System"
line_side = false
font_family = "Monospace"
font_size = 16.0
```
### Options
| Option | Default | Description |
|--------|---------|-------------|
| `auto_hide_toolbar` | `false` | If `true`, the menu bar at the top will be hidden. Move your mouse to the top of the window to reveal it. |
| `show_line_numbers` | `false` | If `true`, line numbers will be displayed on the side specified by `line_side`. |
| `line_side` | `false` | If `false`, line numbers are on the left. If `true`, they are on the right. |
| `word_wrap` | `false` | If `true`, lines will wrap when they reach the edge of the window. |
| `font_family` | `"Proportional"` | The font family used for the editor text. |
| `font_size` | `14.0` | `8.0-32.0` The font size for text editing. |
| `theme` | `"System"` | The color scheme for the application. Options: `"System"` (attempts to use colors from `$XDG_CACHE_HOME/wal/colors` if present, otherwise uses system's light/dark mode preference), `"Light"`, or `"Dark"` (manually specify a theme). |
## Future Plans
In order of importance.
| Feature | Info |
| ------- | ---- |
| **Find/Replace:** | In progress. |
| **State/Cache:** | A toggleable option to keep an application state and prevent "Quit without saving" warnings. |
| **Syntax Highlighting/LSP:** | Looking at allowing you to use/attach your own tools for this. |
| **Choose Font** | More than just Monospace/Proportional. |
| **Vim Mode:** | It's in-escapable. |
| **CLI Mode:** | 💀 |
| **IDE MODE:** | 🤡 |
I use [Helix](https://helix-editor.com/), btw.

View File

@ -109,8 +109,12 @@ pub(super) fn editor_view(
let cursor_pos = cursor_range.primary.index; let cursor_pos = cursor_range.primary.index;
let content = &active_tab.content; let content = &active_tab.content;
let text_up_to_cursor = &content[..cursor_pos.min(content.len())]; // Count newlines up to cursor position using char_indices to avoid char boundary issues
let cursor_line = text_up_to_cursor.chars().filter(|&c| c == '\n').count(); let cursor_line = content
.char_indices()
.take_while(|(byte_pos, _)| *byte_pos < cursor_pos)
.filter(|(_, ch)| *ch == '\n')
.count();
let font_id = ui let font_id = ui
.style() .style()