Git Product home page Git Product logo

cosmic-edit's Introduction

COSMIC Text Editor

Text editor for the COSMIC desktop

Screenshot

Currently an incomplete pre-alpha, this project is a work in progress - issues are expected.

Testing

You can test by installing a current version of Rust and then building with cargo.

git clone https://github.com/pop-os/cosmic-edit
cd cosmic-edit
cargo build

You can get more detailed errors by using the RUST_LOG environment variables, that you can invoke for just that one command like this: RUST_LOG=debug cargo run. This will give you more detail about the application state. You can go even further with RUST_LOG=trace cargo run, that shows all logging details about the application.

Clippy Lints

PRs are welcome, as it builds a better product for everyone. It is recommended that you check your code with Clippy Lints turned on. You can find more about Configuring Clippy here.

cosmic-edit's People

Contributors

ahoneybun avatar aquilesorei avatar ben3291 avatar bittin avatar dengelt avatar duckonaut avatar dygear avatar edfloreshz avatar evacks avatar fabrizioiannetti avatar falexei avatar git-f0x avatar hugok79 avatar jackpot51 avatar joshuamegnauth54 avatar linuxr01 avatar mmstick avatar moi-cest-matthew avatar oguzkarayemis avatar platlas avatar skygrango avatar taylormichaelhall avatar thomasfrans avatar tomlajtos avatar vandalhj avatar wash2 avatar weeesly avatar wiiznokes avatar xalt7x avatar zen-tools avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cosmic-edit's Issues

Time of "Click", Time of Use - Click events do not always propagate correctly.

While trying to track down #85 I found a very subtle little bug. I added log::warn!() with the function name so I could track where the flow was coming from and going to when trying to reproduce that issue. I also added a sleep(Duration::from_millis(1000)); right after it so I could see the results of the function call in human perceivable time. When doing that, if you take your mouse away from the click event, the click event is not registered completely.

This is a failed action log, where I click on the folder i18n that is not yet open in a narrow (<300px window) Cosmic Edit window with the project navigation open. I move my mouse from the i18n location (off the window completely in this case) but before on_nav_select is called.

[2024-01-20T20:45:00Z WARN  cosmic_edit] Application::nav_bar
[2024-01-20T20:45:01Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:45:02Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:45:03Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:45:04Z WARN  cosmic_edit] Application::header_start
[2024-01-20T20:45:05Z WARN  cosmic_edit] Application::subscription
[2024-01-20T20:45:06Z WARN  cosmic_edit] Application::nav_bar
[2024-01-20T20:45:07Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:45:08Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:45:09Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:45:10Z WARN  cosmic_edit] Application::header_start

This is a successful action where I do the same thing -- try to open the i18n folder -- but I keep my mouse hovering over the i18n folder. This time, the whole event is actually followed though with and the folder opens (and the issue I was actually there to reproduce happens).

[2024-01-20T20:47:00Z WARN  cosmic_edit] Application::nav_bar
[2024-01-20T20:47:01Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:47:02Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:47:03Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:47:04Z WARN  cosmic_edit] Application::header_start
[2024-01-20T20:47:05Z WARN  cosmic_edit] Application::subscription
[2024-01-20T20:47:06Z WARN  cosmic_edit] Application::nav_bar
[2024-01-20T20:47:07Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:47:08Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:47:09Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:47:10Z WARN  cosmic_edit] Application::header_start
[2024-01-20T20:47:11Z WARN  cosmic_edit] Application::on_nav_select Entity(6v1)
[2024-01-20T20:47:12Z WARN  cosmic_edit] Clicking Dir: "/home/dygear/cosmic-edit/i18n" and opening true
[2024-01-20T20:47:12Z WARN  cosmic_edit] App::open_folder
[2024-01-20T20:47:13Z WARN  cosmic_edit] Application::subscription
[2024-01-20T20:47:14Z WARN  cosmic_edit] Application::nav_bar
[2024-01-20T20:47:15Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:47:16Z WARN  cosmic_edit] Application::view
[2024-01-20T20:47:17Z WARN  cosmic_edit] Application::context_drawer
[2024-01-20T20:47:18Z WARN  cosmic_edit] Application::nav_model
[2024-01-20T20:47:19Z WARN  cosmic_edit] Application::header_start

You'll notice that I started both of these events at the top of the minute so it's easier to see control. Each function sleeps for 1 second so we get an idea of how many functions inside comsic_edit are actually called. 19 functions for the success case where the the Project Navigator does not remain open, but the file contents are correctly opened after once you click back into the Project Navigator to see it. And only 10 functions when the Project Navigator click is aborted due to the click event not getting captured correctly.

Is this a realistic problem? Maybe not. You'd have to be very resource constrains or just crazy quick with your mouse click and move away for this bug to propagate in real life. But it CAN happen, and people should be aware of it as well. What's really fun is that you can click on debian but then hover over the i18n folder while the function calls are happening and it will close the i18n directory.

I really think that the original click should be captured. I'm interested to see if that's reproducible on like a Raspberry Pi Zero 2 W board. The lower end Raspberry Pi 3-ish level hardware might make this happen in a less contrived state. I'm also not sure if this is actually a bug with cosmic_edit or an iced problem. I'm leaning towards iced, but it was discovered here first. So I'll document it here, and then maybe forward this to iced.

Undo (Ctrl-Z) does not include pastes

Steps to recreate:

  1. Type some text.
  2. Copy and paste the text.
  3. Press Ctrl-Z.

Expected behavior: The paste is undone.

Actual behavior: The more recent pasted text stays there, but the less recent typed text is undone (one character at a time).

Panic when typing to replace text segment

Selecting any segment of text (e.g. holding a mouse button and dragging over the text) and typing to replace it (without first deleting it with backspace) causes cosmic-edit to crash with the following message:

thread 'main' panicked at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/alloc/src/string.rs:1641:9:
assertion failed: self.is_char_boundary(at)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Can't build.

error[E0599]: no method named drain_filter found for struct Vec<CommandItem<T>> in the current scope
file: index.crates.io-6f17d22bba15001f/undo_2-0.2.0/src/lib.rs:1175:31
|
1175 | self.commands.drain_filter(|_| {
| --------------^^^^^^^^^^^^ method not found in Vec<CommandItem<T>>

Typing when text is selected results in panic

cosmic-edit has some very weird behavior when using ctrl+a to select all text when ran under WSL, including panicking. I noticed this when trying out cosmic-edit under WSL in Windows, but it's possible this behavior also exists under native linux (which I'm unable to test right now).

Test setup

I'm running Ubuntu 22.04 WSL and I get cosmic-edit using the nix package manager like so:

nix shell nixpkgs#cosmic-edit --command cosmic-edit

This pulls in version unsable-2023-11-29

Repro

  1. Open cosmic-edit
  2. Type some text, such as test
  3. Select all text using ctrl+a
  4. Overwrite the selected text by typing at least 2 characters. Notice that the first character works correctly but the second will cause a panic.

This outputs the following console log (ERROR and WARN likely due to WSL):

$ nix shell nixpkgs#cosmic-edit --command cosmic-edit
[2024-01-13T23:01:00Z ERROR i18n_embed::requester] Unable to parse your locale: ParserError(InvalidLanguage)
[2024-01-13T23:01:00Z WARN  winit::platform_impl::platform::x11::util::randr] XRandR reported that the display's 0mm in size, which is certifiably insane
thread 'main' panicked at /build/rustc-1.74.0-src/library/alloc/src/string.rs:1641:9:
assertion failed: self.is_char_boundary(at)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

There are other similar cases involving typing with selected text that produce other strange behavior, but I assume they all have the same root cause. For example, the described panic occurs when text is selected and the cursor is at the start of the selection, but typing with the cursor at the end of the selection only results in only the last character being shown on screen.

Click-drags from editor pane register as clicks when released over buttons and controls for the main editor

This is a bit difficult to explain without a video capture, but hopefully I can get the idea across with just this screenshot and a description...

Screenshot_2023-12-12_10-33-19

So I want to click and drag from the very end of the last line in this short file to highlight all of the text in the file. If I drag past the editor pane so that my mouse cursor is over the "Open project" button in the projects pane when I release the mouse button, the Open Project dialog appears, as if I had clicked the button. It seems the rest of the UI also does this, other than the top left button that hides and shows the projects side bar. For some reason that button ignores released clicks as I would expect.

Unsaved file indicator does not disappear after undoing all unsaved changes

Steps to recreate:

  • Open a new tab.
  • Make a single change to it, which should make the unsaved file indicator appear.
  • Undo your change so that the file is returned to its last saved state.
  • Unsaved file indicator does not disappear. I would expect it to disappear since there are now no unsaved changes.

Backup Unsaved Changes

Backup Unsaved Changes

(I have tested every text editor in my OS's package manager and none of them are usable because they are missing these features... I have to use Notepad++ through Wine)
If a text editor isn't usable like a sticky note app, at some point it is going to delete important information without recovery.

1. Correctly remember opened tabs (as well as a browser):

  • 1.1 Auto-Save open tabs: In human readable file, like JSON or TOML (use Cosmic's default, useful like browser's export bookmarks).
  • 1.2 Auto-Save open tabs: In backup folder, like ~ user folder, not a temp folder.
  • 1.3 Auto-Create unnamed files: (File Menu -> New Text File, creates empty file in Documents folder or same backup folder following naming template like "document3". (Location configurable). Reuse first non-opened empty file using the naming template before creating a new one.
  • 1.4 Unnamed file cleanup: Maybe if an empty unnamed file tab is closed, just delete the empty file using the naming template. (Should be safe in backup folder, but may not always be safe in Documents folder).
  • 1.5 Recover tabs from program crash & OS crash: Save on changes to open tabs, not any closing event as they do not fire on crash.
  • 1.6 Handle double open: Do not double open tabs if the program is ran twice. Do not lose list of open tabs, even if either one, or both open processes are closed in any order.
  • 1.7 Closing Windows:
  • Know the difference between user closing a tab, and a close signal from the OS.
  • If there is a single window, remember tabs and close program.
  • If there are multiple windows, closing a window should give a prompt to "Keep tabs & Exit" or "Close tabs in window". (Configurable). Closing unsaved tabs should each sequentially give a "Save", "Close without Saving", or if needed "Delete Unsaved Document".

2. Backup unsaved changes (as well as Notepad++):

  • 2.1 On keyrelease, X-seconds after change, or after X-seconds of idling after change (Configurable, play nice with linters) update a backup/archive copy of the entire file somewhere in ~ user folder. This would be manually findable and recoverable even if the OS couldn't boot. It should have the same access permissions as the original file for security. Do not wait to save on any closing event as they do not fire on crash.
  • 2.2 With 2.1 also backup a little of the undo history (does not have to be plain text nor manually findable, must survive reboot). It should have the same access permissions as the original file for security.
  • 2.3 After program crash, OS crash, or just program was closed: Recover unsaved changes and backed up undo history.
  • 2.4 Clean up: On save, delete backup file, but keep undo history.

3. Watch for changes (like from formatters):

  • 3.1 Do not change timestamp, if there is no change.
  • 3.2 Watch Files: Detect if another program (formatters/linters) has really changed the file contents (not just a timestamp change). Do not show tab as unsaved if the file content has not really changed.
  • 3.3 Auto-Reload: Load changed file without prompt if only simple changes like additions. (Configurable).
  • 3.4 Compare: If non-simple changes to file are detected: Change tab into a "Compare" tab that shows a side-by-side (diff) with options like: Keep On-disk (left), Keep Unsaved (right), Rename On-disk (left), Rename Unsaved (right). (Configurable auto-selection per file type or maybe project folder).
  • 3.5 Compare Recovery: Menu-option/UI-button to recover/undo if the user clicked the wrong compare button (backup/archive other choice for a bit, must survive a reboot).

4. Misc:

  • 4.1 Copy on write: All file saves should be copy on write, maybe detect if the format of the hard drive enforces it, otherwise do it yourself. Keep backup archives as needed (like ability to recover if the user clicked the wrong compare button). Error on the side of converting to a "Compare" tab instead of deleting changes the user may still want.
  • 4.2 Any unsaved tab has a menu-option/UI-button to be converted into a "Compare" tab that shows a side-by-side with the On-disk file, see 3.4.

5. Far future stretch goal:

  • 5.1 Compare Merge: Also show side-by-side column of automatic merge, that you can directly edit and make choices per conflict. Option: Keep Merge (center). See 3.4.
  • 5.2 Understand the Git merge format, auto-detect it, and open these files in a "Compare" tab, see 3.4.

LSP integration

I feel like this is a given for a modern text editor that is meant to program in, but important enough to mention.

I'm very excited to see how far this text editor will go! Best of luck

Panic when trying to open file

Opening - ABC.zip

will crash with message

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `2`,
 right: `1`', /home/rafal/.cargo/git/checkouts/cosmic-text-92dc585b4973ff15/e788c17/src/shape.rs:447:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Cosmic Text Editor Neovim Client Support

Hi there,

As vim is one of the more populator text editors on Linux, it seems desirable to add a "vim mode" to the text editor. In days past this would have consisted in implementing a small subset of vim keybindings into the text editor manually. Nowadays, however, this task of integrating vim can be done in a much more effective and simpler way. Neovim, which is vim's modern replacement, is designed with a client/server architecture. So you can add a thin Neovim client into the Cosmic Text Editor that talks to the real Neovim backend (server) thereby providing a full authentic vim experience (all the keybindings, loading of .vimrc files, customizations, etc.). For example, you could google "Neovim frontend" to see other GUI frontends to neovim that people have created.

If the Cosmic Text Editor could be given a builtin Neovim client then it could function as a drop-in replacement for any user's full Neovim setup with little effort on either the part of System76 or on the user.

Allow disabling newline at end of file

Right now, COSMIC Text adds a newline to the end of all files. This is nice because it means e.g. the output looks nicer when cating a file (doesn't cause the terminal prompt to end up not being on its own line). POSIX tools and some programming languages expect files to end with a newline.

However, this currently means it's impossible to remove that newline if a user wants to, or to edit a file without an ending newline without adding it (this is a common extra thing that shows up in git diffs). It would be nice if we had a setting to control whether a newline is added or not, so that can be turned off.

For reference, both Gedit and KWrite also do this by default, but KWrite allows turning it off. Here's what the option looks like in the KWrite settings:

image

Gedit seems to have a hidden dconf/gsettings setting for this that's not available in its GUI.

Crashes after suspend/resume

Same issue as pop-os/cosmic-term#12. If I have COSMIC Text open and I suspend/resume, then it's no longer open. I see the following in the logs:

Dec 27 15:32:22 serw13 com.system76.CosmicEdit.desktop[16264]: thread 'main' panicked at /build/cosmic-edit-DLyCcn/cosmic-edit-0.1.0~1703632828~22.04~cbb0f89/vendor/wgpu/src/backend/direct.rs:822:30:
Dec 27 15:32:22 serw13 com.system76.CosmicEdit.desktop[16264]: Error in Surface::get_current_texture_view: Validation Error
Dec 27 15:32:22 serw13 com.system76.CosmicEdit.desktop[16264]: Caused by:
Dec 27 15:32:22 serw13 com.system76.CosmicEdit.desktop[16264]:     Parent device is lost
Dec 27 15:32:22 serw13 com.system76.CosmicEdit.desktop[16264]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Looks like some kind of wgpu issue.

No confirmation when exiting with unsaved changes

Some kind of dialog asking if the user wants to save & quit or quit without saving should probably be added. Currently, the app just closes, discarding unsaved changes:

simplescreenrecorder-2023-11-28_17.52.46.mp4

Other apps' dialogues:

Gedit:

New file:

image

Existing file:

image

KWrite:

New file:

image

Existing file:

image

Capturing Enter keypresses coming off of other apps' focus

When using COSMIC Edit on GNOME, if I take these steps:

  1. Have COSMIC Edit focused
  2. Open the Launcher, search for some other app (e.g. calculator), and open it with Enter

COSMIC Edit receives the Enter keypress and adds a line break before my focus is switched to the Calculator. Gedit and KWrite don't do this. I'd expect the Launcher to be the only thing to receive that Enter keypress since it's what's focused at the time of pressing the key.

This also happens if I focus COSMIC Edit, lock the GNOME session, and go to unlock it (typing the password and pressing Enter). Interestingly, if I enter a wrong password, COSMIC Edit still receives the Enter keypress-- I can enter an incorrect password multiple times (pressing Enter after each one) and then observe multiple line breaks in COSMIC Edit after successfully unlocking the session.

Issue when compiling

I downloaded this repository to test this but when I tried to build it it ran this error:

Compiling freetype-sys v0.13.1 Compiling servo-fontconfig-sys v5.1.0 Compiling iced_core v0.9.0 (https://github.com/pop-os/libcosmic?rev=a8ce524baa58f4fb2db2e26a5fc0899b63d688b5#a8ce524b) Compiling smithay-client-toolkit v0.16.0 Compiling gobject-sys v0.15.10 Compiling atk-sys v0.15.1 Compiling gdk-sys v0.15.1 Compiling pango-sys v0.15.10 Compiling clipboard_x11 v0.4.0 Compiling gdk-pixbuf-sys v0.15.10 Compiling cairo-sys-rs v0.15.1 Compiling tracing v0.1.37 Compiling syntect v5.1.0 Compiling env_logger v0.9.3 Compiling fontdb v0.9.3 error: failed to run custom build command forservo-fontconfig-sys v5.1.0`

Caused by:
process didn't exit successfully: /home/nathanael/Documents/Development/Rust/cosmic-text-editor-master_jammy/target/debug/build/servo-fontconfig-sys-1df7a7ca5f04f38d/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=FONTCONFIG_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=FONTCONFIG_STATIC
cargo:rerun-if-env-changed=FONTCONFIG_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
thread 'main' panicked at 'PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "fontconfig" "fontconfig >= 2.11.1" did not exit successfully: exit status: 1
error: could not find system library 'fontconfig' required by the 'servo-fontconfig-sys' crate

--- stderr
Package fontconfig was not found in the pkg-config search path.
Perhaps you should add the directory containing fontconfig.pc' to the PKG_CONFIG_PATH environment variable No package 'fontconfig' found Package fontconfig was not found in the pkg-config search path. Perhaps you should add the directory containing fontconfig.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fontconfig' found
', /home/nathanael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/servo-fontconfig-sys-5.1.0/build.rs:34:17
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
The following warnings were emitted during compilation:

warning: PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "atk" "atk >= 2.18" did not exit successfully: exit status: 1

error: failed to run custom build command for atk-sys v0.15.1

Caused by:
process didn't exit successfully: /home/nathanael/Documents/Development/Rust/cosmic-text-editor-master_jammy/target/debug/build/atk-sys-d67f0e66760d5b61/build-script-build (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=ATK_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:warning=PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "atk" "atk >= 2.18" did not exit successfully: exit status: 1
error: could not find system library 'atk' required by the 'atk-sys' crate

--- stderr
Package atk was not found in the pkg-config search path.
Perhaps you should add the directory containing atk.pc' to the PKG_CONFIG_PATH environment variable No package 'atk' found Package atk was not found in the pkg-config search path. Perhaps you should add the directory containing atk.pc'
to the PKG_CONFIG_PATH environment variable
No package 'atk' found

The following warnings were emitted during compilation:

warning: PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "pango" "pango >= 1.38" did not exit successfully: exit status: 1

error: failed to run custom build command for pango-sys v0.15.10

Caused by:
process didn't exit successfully: /home/nathanael/Documents/Development/Rust/cosmic-text-editor-master_jammy/target/debug/build/pango-sys-9d350229ce4372a1/build-script-build (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=PANGO_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:warning=PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "pango" "pango >= 1.38" did not exit successfully: exit status: 1
error: could not find system library 'pango' required by the 'pango-sys' crate

--- stderr
Package pango was not found in the pkg-config search path.
Perhaps you should add the directory containing pango.pc' to the PKG_CONFIG_PATH environment variable No package 'pango' found Package pango was not found in the pkg-config search path. Perhaps you should add the directory containing pango.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pango' found

error: failed to run custom build command for gdk-sys v0.15.1

Caused by:
process didn't exit successfully: /home/nathanael/Documents/Development/Rust/cosmic-text-editor-master_jammy/target/debug/build/gdk-sys-20c14a7772b783ff/build-script-build (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=GDK_3.0_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "gdk-3.0" "gdk-3.0 >= 3.18" did not exit successfully: exit status: 1
error: could not find system library 'gdk-3.0' required by the 'gdk-sys' crate

--- stderr
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing gdk-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gdk-3.0' found Package gdk-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containing gdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found

The following warnings were emitted during compilation:

warning: PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "cairo" "cairo >= 1.14" did not exit successfully: exit status: 1

error: failed to run custom build command for cairo-sys-rs v0.15.1

Caused by:
process didn't exit successfully: /home/nathanael/Documents/Development/Rust/cosmic-text-editor-master_jammy/target/debug/build/cairo-sys-rs-3de1debd2ce2fb0a/build-script-build (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=CAIRO_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:warning=PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "cairo" "cairo >= 1.14" did not exit successfully: exit status: 1
error: could not find system library 'cairo' required by the 'cairo-sys-rs' crate

--- stderr
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing cairo.pc' to the PKG_CONFIG_PATH environment variable No package 'cairo' found Package cairo was not found in the pkg-config search path. Perhaps you should add the directory containing cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
`
I'm running Pop!_OS what am I doing wrong?

Extreme memory usage and slow loading of moderately sized text file

Out of curiosity I decided to try my usual editor benchmark with cosmic-text-editor: Opening sqlite3.c (a ~9 MB file which you can download here).

Results:

  • Even in release mode, it took around a minute to load.
  • It uses almost 3 GB of RAM! For a 9 MB file! In other words, it inflates the actual useful data by a factor of 300 (times, not percent).

For comparison:

  • Sublime Text 3 loads the file in around 2 seconds and uses 300 MB of memory.
  • Vim loads it instantaneously and uses 34 MB of memory (but disables syntax highlighting) .
  • Mousepad (GTK-based editor from Xfce) loads it in around 10 seconds and uses 150 MB of memory.

I understand that this project is still in its infancy, but you might want to address performance before you develop this any further.

MSRV & Style Guide

Is there an already accepted MSRV and style guide for any of the Cosmic crates? I was compiling this on my MacBook and two general errors popped out with the regular debug build. With Clippy lints enabled, many more come to the surface. Are these things that should be fixed?

src/textbox:rs 121:123

    if alpha == 0 {
        // Do not draw if alpha is zero
        return;
    } else if alpha >= 255 {

This is currently an unneeded return but could be an important placement in later versions should the if structure change later on.

src/textbox.rs 175

impl<'a, 'editor, Message, Renderer> Widget<Message, Renderer> for TextBox<'a, Message>

The 'editor lifetime isn't used in the impl at this time. Should this be removed?

src/textbox.rs 236:239

        match &state.dragging {
            Some(Dragging::Scrollbar { .. }) => return mouse::Interaction::Idle,
            _ => {}
        }

This could be a let if statement as it really only has a single match.

src/textbox.rs 511

        let image_position = layout.position() + [self.padding.left as f32, self.padding.top as f32].into();

self.padding.left and self.padding.top is already f32. I assume this was a left over from a pervious version that was an i32 or u32? But the conversion here is now not needed.

src/textbox.rs 807

impl<'a, 'editor, Message, Renderer> From<TextBox<'a, Message>> for Element<'a, Message, Renderer>

The 'editor lifetime is not used in this impl at all and can be removed.


I ask about all of these things, as I want to make sure I'm not tripping over a style guide for these family of crates. I also want to point out that I'm only the textbox file as an example not to pick on anyone. This file was just as an area where clippy had some varied examples in its list. I'm extremely impressed with the work here and would love to help, in any way that I can.

font warnings

cool, thanks for creating this! added an arch linux package here, https://aur.archlinux.org/packages/cosmic-text-editor-git, debug build. running feels a little sluggish, not sure if the debug mode is the reason, or the font warnings it prints:

[2023-03-09T12:42:46Z INFO  cosmic_text::font::system::std] Locale: en-US
[2023-03-09T12:42:46Z INFO  cosmic_text::font::system::std] Parsed 291 font faces in 19ms.
[2023-03-09T12:42:46Z INFO  cosmic_text::font::system::std] Mapped 291 font faces in 19ms.
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z INFO  cosmic_text_editor::text_box] size Size { width: 992.0, height: 20.0 }
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'DejaVu Sans'
[2023-03-09T12:42:47Z WARN  cosmic_text::font::fallback] failed to find family 'FreeSans'
<and so on ...>

No horizontal scrolling (text gets cut off when wrapping is disabled)

Version: 8996394

Issue description: When the length of a line of text extends beyond the size of the window and text wrapping is disabled, the text is simply cut off. The cursor can be moved past the end of the window with the keyboard, and the non-visible text can be modified, but the view can't be scrolled so the end of the text is visible.

Expected behavior: The view should be horizontally scrollable when text wrapping is disabled and the text extends past the edge of the window. Moving the cursor (or typing anything) past the edge of the window should scroll automatically so the cursor remains visible. Ideally, a horizontal scrollbar should be visible to indicate when the view is scrollable.

Example:

simplescreenrecorder-2023-11-28.17.47.28.mp4

Tab doesn't work on empty lines

If I hit Enter to start a new line, hitting Tab does not indent that line until I type a character on the line. Once there is a character present, hitting Tab indents the line.

Raspberry Pi OS & Raspberry Pi 5 (Missing Icons & Blank Text Area)

Last night I compiled cosmic-epoch on the Raspberry Pi 5, using Raspberry Pi OS. There were only two hiccups between a successful compile and the instructions. The first being that just is not found in the Debian packages at the moment, but that was easily fixed after running cargo install just. The second one was pop-launcher. just is a requirement for building the cosmic-epoch crate, but pop-launcher is not.

I built cosmic-epoch overnight and started cosmic-edit once installed. One, tiny little problem. tho. The icons do not show up for closing a window, maximize, and minimize as well as the "hamburger menu" on the left side for the file tree. The icon area are clickable, and function as expected they are just missing or not rendered. I installed pop-launcher thinking that maybe the icons were missing from that package, but after doing a git clone https://github.com/pop-os/launcher.git and then a just build-release and just install there were still no icons.

The slightly more pressing issue is the text area renders as just blank. Same blank / black color as the missing icon area. I originally thought that these were separate issues, but I think that they may share a render pipeline and so the problem is actually comes from the same area. Going to investigate further.

Scrollbar doesn't reflect actual length of file

The scrollbar initially shows a single pixel row at the top; I'm not sure if that's expected or not.

When adding a second line to the file, the scrollbar appears as if the file is only halfway in view. It can't actually be moved/scrolled because the file isn't actually that long.

The scrollbar doesn't begin behaving somewhat as expected until the file is actually scrollable, although the scrollbar never reaches the bottom of the page.

simplescreenrecorder-2023-11-15_16.18.40.mp4

Text area can be scrolled one line past the length of the file

The scrollbar indicates that the last line of text is the end of the file. However, it can still be scrolled one more notch, which shrinks the scrollbar and adds a line that can't be interacted with.

simplescreenrecorder-2023-11-16_14.45.41.mp4

Is this intentional? (Wasn't sure if it had to do with indicating the file has a newline at the end or something.) When the editor is vertically resized so it doesn't cut off right at a line, it can end up causing a significant gap between the text and the bottom of the window.

image

Text area goes away when closing settings pane with the mouse

To recreate:

  • Have a document open with some text in it
  • Open View > Settings pane (or with ctrl + comma hotkey)
  • Click the "Close >" button in the Settings pane
  • The document vanishes. It looks like the lighter rectangle behind it might be popping up in front of it. Clicking the document area makes it re-appear.
2023-11-02_12.10.50.mp4

Closing the Settings pane with Ctrl + comma does not make the document vanish, but a comma is inserted into the document upon closing the pane. The comma probably shouldn't be added to the document when using that hotkey to close the Settings pane.

Ctrl-A (select all) in Find dialogue also selects all in main text area

Version: abf0ea0

Description: If I'm typing in the Find toolbar and I press Ctrl-A to select my search term, the main text area is selected as well. Sometimes, when I start typing to replace my search term with a new one, it actually replaces the contents of the text file with what I'm typing.

Expected behavior: If my cursor is in the Find box, Ctrl-A should only select the Find box, and typing after that should only type into the Find box.

Theme and Syntax highlighting adjustment

In the View menu

  • Remove "View > Syntax highlighting..."

In Settings

  • Rename current "Theme" option to "Syntax highlighting"
  • Add Theme above "Syntax highlighting". Theme is intended to be a system appearance override. Options in the dropdown should be "Match desktop" (default) "Light" and "Dark"

With syntax highlighting following light and dark modes, I think we can do something better to expose to the user that there are actually two settings. Perhaps "Syntax dark" and "Syntax light".

Icons inappropriately appearing when context menus are opened.

The icons within the hamburger / project menu are visible when opening another context menu, even with that menu collapsed. I checked and it's present in the most current version of comsic-edit. Not sure when it happened, so I'm conducting an investigation.

Screenshot from 2024-01-18 01-05-29

Change and add shortcuts

New file: Ctrl + T
New window: Ctrl + N
Close file (under open file): Ctrl + W
Open project (under close file): Ctrl+Shift+O

Change "Open recent >" to "Open recent file >"
Add "Open recent project >" underneath

Kakoune/Helix editing model

both text editors use a selection then action model rather then vims model and I have found it to be much more user friendly with command discovery being much better.

Tree view is not navigatable in single column view

  • Reduce the window to a single column
  • Open the NavBar
  • Open a project
    • NavBar should remain open and display the directory contents
  • Open the NavBar
  • Click a directory
    • NavBar should remain open unless a file is opened

libcosmic tabs issues

COSMIC Edit is the first instance of libcosmic tabs needing more refined functionality.

The design for tabs: https://www.figma.com/file/SkAtS5qlVOGQC0n895AHzX/Design-System-(WIP)?type=design&node-id=7914-5446&mode=design&t=NKlxg637660dOibH-0

Issues

  • Tabs do not contract cleanly. The design suggest moving to a dropdown menu but we should consider other options like horizontal scroll with controls similar to Firefox.
  • Text overlaps the close icon. The design file suggest moving to ellipses.
  • Text on an active tab can overlap the tab boundary
  • The document icon is the same for all files I've opened. This doesn't seem useful.
  • An unsaved indicator, as described in the design file would be useful
  • Tabs look about 10% too tall compared to the design (cosmic-edit design for additional reference)

@maria-komarova please review and add your thoughts.

libcosmic-tabs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.