Building a simple text editor with iced, a cross-platform GUI library for Rust
ฝัง
- เผยแพร่เมื่อ 19 พ.ค. 2024
- Learn the basics of iced-a cross-platform GUI library for Rust-and build a cool, simple text editor in the process!
00:00:00 Introduction
00:02:04 Initial setup
00:03:59 Hello, iced!
00:11:00 Multi-line text input
00:15:53 The debug view
00:17:46 Dark theme and cursor indicator
00:21:14 Async file loading
00:31:07 Native file picker
00:38:04 File path tracking
00:42:46 New and save interactions
00:53:26 Font loading and custom icons
01:02:22 Tooltips and styling
01:05:01 Syntax highlighting
01:09:12 Theme picker
01:12:55 Subscriptions and save hotkey
Man, if the docs have at least a little amount of content, this framework will become super popular
There are plenty of examples though and there are docs. The docs are just not beginners friendly, so stop being beginners.
@@Notoriousjunior374 Sorry I forgot to take the pill to be a senior rust developer...
@@Notoriousjunior374 thanks for reminding me that i'm inferior
@@Notoriousjunior374 Ohh, just "git gud"
agree
I am already hooked. I love that it has "Update" and "View" as separate methods, creating excellent isolation of mutable & immutable blocks. modern frameworks combine them making it more complicated.
This was perfect thank you! I'm new to rust and was interested in building an editor as way to learn. I hope you do more. Also love Iced so far!
This is a really good tutorial of Iced! Thanks for doing this!
Can't wait for 0.12 to come out, these new features are really useful
Thank you so much for this video, I'm just starting with Rust, app development and Iced all at once and this video has been definitely very helpful! Hopefully more to come!
Great tutorial! As a Rust newbie, I would love to see more on custom styling. Thanks again for this exciting framework!
Absolutely love this!
Awesome, will be using your framework from now on. Looking forward to it! :)
This is incredible. Im beginner learning rust after C and Raylib and Iced looks great but couldn't find any tutorial.
The most informative introduction of any framework! Good luck with the project!🤩
And the most complete one!
@@iced-rs Yes! It feels like I've learned much more than just the framework because you perfectly showed a really useful example!
Hector and ice goes well together
I just wanna say, excellent tutorial! Everything was very clear and easy to understand, and I made my first iced app with this. Thanks for the hard work!
Really had fun learning with your video, with the amount of things I have learned, I am going to try to make something myself. Looking forward to more such tutorials
Thank you for the awesome work 🙏
love the tutorial. just the level of detail I need to get started
Thank you for this great demo!
Please make documentation, we are all very much waiting, and it would be very cool if once a week would be released some tutorial on the example of a small project, thank you very much!👍👍👍
Didn't even know you guys had a channel, nice
Fantastic tutorial! I learned a lot. Thanks!
This is great! More video like this would be very welcome. If I may suggest a topic, advanced use of subscriptions would be good to have more material on.
seconding this
You make it look so easy
Thanks for this!
Amazing work!
thank you hector
I'm hooked!
Great content and very didactic to help me chose iced over egui.
I've devoted about a year to egui, and at work we use Tauri for alot our applications (mostly because we wanted to reuse React code). But damn, Iced is clean, if that documentation was even somewhat existent, this would absolutely take off.
I LOVE IT
Hope that the text editor widget can be launched on stablized versions
This is an awesome video and I'm really excited about using Iced in some personal projects. I noticed that the editor doesn't respond to the tab keypress to indent in the editor. I went poking around a little bit to see if I could figure out why not, but got a little lost inside source. Any insights on the tab key? One minor comment for future videos,, you type quite fast and slowing down just a little bit would help those coding along so we don't have to keep pausing the video. :)
This would need to be implemented by the user, since this use case is specific to code editing and the text editor widget is meant to be relatively use-case agnostic.
@@iced-rs That makes sense, thanks!
What are some good resources i could look into for using WASM to get this to run online? I'm trying to make a little editor for my org files
ahhh yes, the most complete ui-framework
If suppose someone made notes while learning and shared. Would that help later on with docs? Just asking.
Nice video! How did you get a terminal inside helix btw :)
It's a floating pane of my terminal multiplexer, Zellij: zellij.dev/ Also built with Rust!
@@iced-rs :0 thank you!
the debug feature prints number all over the window... is there a bug?
Love you work!
Hi! Great video. How do you execute cargo run? How do you configure Zellij?
This is my Zellij layout for working on Rust projects: gist.github.com/hecrj/cf1a60529afd070b6de993fa5d76b9fc
@@iced-rs Thanks
I love you.
How could I implement line numbering?
I've tried a few things, but the issue is I can't clone/modify a Content arbitrarily or track things like scroll effectively. It also doesn't seem like it's possible built-in.
I tried cloning iced and modifying the editor to add a ".numbered()" function, but even then I couldn't figure it out as the rendering code was too complicated for me to understand.
im having problems in the display of the font icons, for some reason it shows a rectangular icon instead of the one that should be placed. i downloaded the font placing the one i choose and placed the ttf file in the fonts folder, but still i get no icon. any ideas?
Make sure you are using the name you chose before downloading the font everywhere! Also, double-check the codepoints; they may be different for you.
@@iced-rs i fixed it by replacing a letter code of the utf with the icon code in the website
Does it support docking?
Please make more tutorials
How did you have a pop up terminal at 3:30? Is that through helix or zellij?
i wondered the same... i think it's via zellij: ctrl+p w
@@qtfimik42ctrl+shift+c, You can set default terminal from settings
Great video! I'm in love with this font, what's its name?
The one I use in my terminal is called Hasklig, although I use the Nerd Font variant: Hasklug Nerd Font.
Alright fellas load_file keeps throwing this error "functions in traits cannot be declared `async`" anyone seen a resolution for this problem?
I'm tryna learn this as beginner. But docs aren't ready. I'm just looking at the examples and here and there. Which works kinda but slow. Docs with some projects around would be great
Indeed. The project isn't ready for beginners yet! Docs (and more) are coming.
Hows the progress coming along? :)
Question. Where did the "text_editor" vanish too? Checked the crate code and it is no longer there. Version 0.10.0 Can't find it on version 0.9.0 either.
As I point out in the video, the text editor widget hasn't been released yet. You can either use it by relying on the `master` branch or the `text-editor` tag of the official repository.
@@iced-rs My bad. I misread the code. Derp! Thought that the "text_input" was a widget in the Iced crate. Sorry.
Thanks for that. Please do a video about multi screen applications. Maybe enhance the text editor with a markdown preview dialog or something.
Also the fonts field is not available in iced stable or master branch. How to use icon buttons using stable iced version?
EDIT: Got it: font::load(include_bytes!("path/to/icons.ttf").as_slice())
Multi-window support hasn't landed yet, but it is scheduled for the next release!
I know. I meant multi screen. Different screens in one window.
im getting this compile error.
`palette` is ambiguous
ambiguous because of multiple potential import sources
use `::palette` to refer to this crate unambiguously
use `self::palette` to refer to this module unambiguously
Fixed: with this replacement: use crate::theme::palette::Palette; instead of what it was before which I think was pub use palette::Palette
Update your Rust toolchain and the issue should be fixed! Try `rustup update`.
I see, thanks!@@iced-rs
hay man sorry to bother you again im at the stage of adding the async bit into the code so when I run the code it complains about thread '' panicked at 'requires the `rt` Tokio feature flag' the funny thing is I am using the exact version as the one you typed in the tutorial, its asking me to put rt in the features section, which I do and then it complains about reactor not running with this error: thread '' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime' so what is happening I followed the tutorial up to this point exactly and I cant progress because of this.@@iced-rs
@@Dragon20C Try running `cargo update`. If that doesn't work, try enabling the `tokio` feature for the `iced` dependency. I forgot to include that part in the video; I updated the tag yesterday so that it's no longer necessary to enable it manually.
alright it works now, I think you should make a pinned comment about this so other users dont get confused or experience this issue.@@iced-rs
WE RECIEVE IT fOR UGANDA TOO
It might be useful to mention that the code shown already creates a minimize, maximize and close button on most platforms.. it is just that the presenter chose to use a windowing system with their OS which doesn't show those items 😂
What linux is that
Arch Linux.
i want to like this project, i just can't because the docs are absolute trash. i have to watch a video to find that Sandbox is more suitable for "getting started" than Application, which the examples are in. hard pass.
i also want to note that being deaf and having to *watch* documentation is asinine because the automatic captions cover the text you're typing, AND they are awful on their own so... way to be accessible?
@@lareamondmobile Being deaf doesn't give you the right to be entitled and ungrateful. This library is a gift, and I want to remind you that you simply do not have to use it. No one is forcing you.
In any case, if you are so annoyed by watching a video, maybe you could have digged a bit and realize that we actually have an API reference in docs.rs
Here's Application: docs.rs/iced/latest/iced/application/trait.Application.html
> An Application can execute asynchronous actions by returning a Command in some of its methods. If you do not intend to perform any background work in your program, the Sandbox trait offers a simplified interface.
Here's Sandbox: docs.rs/iced/latest/iced/trait.Sandbox.html
> A sandboxed Application. If you are a just getting started with the library, this trait offers a simpler interface than Application.
We also have a Discord server were we gladly help new users: discord.gg/3xZJ65GAhd
You will have to learn to be grateful first, though. Good luck with that!