Building a simple text editor with iced, a cross-platform GUI library for Rust

Поделиться
HTML-код
  • Опубликовано: 13 июл 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

Комментарии • 105

  • @4strodev
    @4strodev 9 месяцев назад +147

    Man, if the docs have at least a little amount of content, this framework will become super popular

    • @Notoriousjunior374
      @Notoriousjunior374 7 месяцев назад +3

      There are plenty of examples though and there are docs. The docs are just not beginners friendly, so stop being beginners.

    • @4strodev
      @4strodev 7 месяцев назад +89

      @@Notoriousjunior374 Sorry I forgot to take the pill to be a senior rust developer...

    • @norliegh
      @norliegh 7 месяцев назад +20

      ​​​​@@Notoriousjunior374 thanks for reminding me that i'm inferior

    • @foofighterdaz
      @foofighterdaz 7 месяцев назад +9

      @@Notoriousjunior374 Ohh, just "git gud"

    • @timoxx8543
      @timoxx8543 6 месяцев назад

      agree

  • @skytech2501
    @skytech2501 9 месяцев назад +16

    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.

  • @program7592
    @program7592 25 дней назад

    I root for the success of iced so much, IMO it has the best development ergonomics in the entire rust GUI ecosytem. Thanks for the video and for all the hardwork!

  • @mrmaymanalt
    @mrmaymanalt 3 месяца назад +2

    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!

  • @pyroraptor07
    @pyroraptor07 9 месяцев назад +3

    This is a really good tutorial of Iced! Thanks for doing this!

  • @jamesb1559
    @jamesb1559 Месяц назад +1

    I have been using Egui and Slint UI tools for Rust, and have long looked at iced. This video makes a strong case for switching !

  • @auralluring
    @auralluring Месяц назад +1

    this might very well be the most useful video i've ever watched. definitely a great way to spend an hour and a half

  • @yournamehasbeentaken9752
    @yournamehasbeentaken9752 8 месяцев назад +13

    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!

  • @mariinkys
    @mariinkys 6 месяцев назад

    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!

  • @krabat6117
    @krabat6117 5 месяцев назад +1

    Awesome, will be using your framework from now on. Looking forward to it! :)

  • @kommentlezz
    @kommentlezz 9 месяцев назад +21

    The most informative introduction of any framework! Good luck with the project!🤩

    • @iced-rs
      @iced-rs  8 месяцев назад +7

      And the most complete one!

    • @kommentlezz
      @kommentlezz 8 месяцев назад +1

      @@iced-rs Yes! It feels like I've learned much more than just the framework because you perfectly showed a really useful example!

  • @starlordcodes
    @starlordcodes 7 месяцев назад +1

    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

  • @redhawk3385
    @redhawk3385 9 месяцев назад +2

    Can't wait for 0.12 to come out, these new features are really useful

  • @tracer4278
    @tracer4278 6 месяцев назад +2

    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!👍👍👍

  • @el_carbonara
    @el_carbonara 8 месяцев назад

    love the tutorial. just the level of detail I need to get started

  • @brucebotes9075
    @brucebotes9075 5 месяцев назад

    Thank you for this great demo!

  • @thebashpotato
    @thebashpotato 4 месяца назад +1

    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.

  • @cazdotsys
    @cazdotsys 9 месяцев назад +1

    Absolutely love this!

  • @undefined_x00
    @undefined_x00 7 месяцев назад +1

    Amazing work!

  • @swez4587
    @swez4587 6 месяцев назад

    Fantastic tutorial! I learned a lot. Thanks!

  • @hagimo_dev
    @hagimo_dev 9 месяцев назад

    Thank you for the awesome work 🙏

  • @yds6268
    @yds6268 8 месяцев назад +1

    Didn't even know you guys had a channel, nice

  • @echoptic775
    @echoptic775 7 месяцев назад +2

    Hector and ice goes well together

  •  8 месяцев назад +1

    Thanks for this!

  • @indierusty
    @indierusty 9 месяцев назад +2

    This is incredible. Im beginner learning rust after C and Raylib and Iced looks great but couldn't find any tutorial.

  • @henrispriet9812
    @henrispriet9812 2 месяца назад +1

    You make it look so easy

  • @workflowinmind
    @workflowinmind 5 месяцев назад

    I'm hooked!

  • @xbz24
    @xbz24 8 месяцев назад

    thank you hector

  • @hanamjaa
    @hanamjaa 8 месяцев назад +1

    I LOVE IT

  • @FabianVilersBe
    @FabianVilersBe 5 месяцев назад

    Great content and very didactic to help me chose iced over egui.

  • @avsaase
    @avsaase 9 месяцев назад +3

    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.

    • @Dworv
      @Dworv 6 месяцев назад

      seconding this

  • @steamedeggeggegg
    @steamedeggeggegg 9 месяцев назад +1

    Hope that the text editor widget can be launched on stablized versions

  • @letronix6243
    @letronix6243 8 месяцев назад

    I love you.

  • @smashedpotato278
    @smashedpotato278 21 день назад

    Great Video!! Thanks for the tutorial it really helped. Is there any way to add highlighter for a custom language or custom syntax highlighting? If you could share any resource on this- that would be really helpful.

  • @joshuajones2643
    @joshuajones2643 7 месяцев назад

    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

  • @PragandSens
    @PragandSens 8 месяцев назад

    ahhh yes, the most complete ui-framework

  • @akza0729
    @akza0729 7 месяцев назад

    If suppose someone made notes while learning and shared. Would that help later on with docs? Just asking.

  • @th3oth3rjak3_
    @th3oth3rjak3_ 9 месяцев назад +2

    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. :)

    • @iced-rs
      @iced-rs  9 месяцев назад +4

      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.

    • @th3oth3rjak3_
      @th3oth3rjak3_ 9 месяцев назад +1

      @@iced-rs That makes sense, thanks!

  • @shastri3303
    @shastri3303 23 дня назад

    The theme part is a bit tricky. I completely relied on the video for that. It would be better if you could provide some documentation for it.

  • @DylanMatthewTurner
    @DylanMatthewTurner 3 месяца назад

    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.

  • @fabiozucconi7068
    @fabiozucconi7068 4 месяца назад

    the debug feature prints number all over the window... is there a bug?
    Love you work!

  • @VBB9999
    @VBB9999 Месяц назад

    does this toolkit have UI files? like .ui in GTK or .axaml in Avalonia?

  • @Kfoo-dj4md
    @Kfoo-dj4md 8 месяцев назад +1

    Nice video! How did you get a terminal inside helix btw :)

    • @iced-rs
      @iced-rs  8 месяцев назад +4

      It's a floating pane of my terminal multiplexer, Zellij: zellij.dev/ Also built with Rust!

    • @Kfoo-dj4md
      @Kfoo-dj4md 8 месяцев назад

      @@iced-rs :0 thank you!

  • @DiscoveringComputers
    @DiscoveringComputers 7 месяцев назад

    Please make more tutorials

  • @pijusmagnificus6382
    @pijusmagnificus6382 9 месяцев назад

    Hi! Great video. How do you execute cargo run? How do you configure Zellij?

    • @iced-rs
      @iced-rs  9 месяцев назад +2

      This is my Zellij layout for working on Rust projects: gist.github.com/hecrj/cf1a60529afd070b6de993fa5d76b9fc

    • @pijusmagnificus6382
      @pijusmagnificus6382 9 месяцев назад

      @@iced-rs Thanks

  • @parallelno
    @parallelno 5 месяцев назад

    Does it support docking?

  • @frostedson9317
    @frostedson9317 4 месяца назад

    WE RECIEVE IT fOR UGANDA TOO

  • @EDToasty
    @EDToasty 7 месяцев назад +1

    How did you have a pop up terminal at 3:30? Is that through helix or zellij?

    • @qtfimik42
      @qtfimik42 6 месяцев назад

      i wondered the same... i think it's via zellij: ctrl+p w

    • @sanjeevshrestha5049
      @sanjeevshrestha5049 4 месяца назад

      @@qtfimik42ctrl+shift+c, You can set default terminal from settings

  • @swordelf4689
    @swordelf4689 3 месяца назад

    Great video! I'm in love with this font, what's its name?

    • @iced-rs
      @iced-rs  3 месяца назад

      The one I use in my terminal is called Hasklig, although I use the Nerd Font variant: Hasklug Nerd Font.

  • @huairuo
    @huairuo Месяц назад

    Excuse me, how can I set an icon for the app?

  • @Ryco117
    @Ryco117 4 месяца назад

    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 😂

  • @TheD3adlysin
    @TheD3adlysin 6 месяцев назад

    Alright fellas load_file keeps throwing this error "functions in traits cannot be declared `async`" anyone seen a resolution for this problem?

  • @user-bm6mo3xo4i
    @user-bm6mo3xo4i 9 месяцев назад

    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?

    • @iced-rs
      @iced-rs  9 месяцев назад

      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.

    • @user-bm6mo3xo4i
      @user-bm6mo3xo4i 9 месяцев назад

      @@iced-rs i fixed it by replacing a letter code of the utf with the icon code in the website

  • @niamotullah99
    @niamotullah99 4 месяца назад

    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

    • @iced-rs
      @iced-rs  4 месяца назад +1

      Indeed. The project isn't ready for beginners yet! Docs (and more) are coming.

    • @Vancha112
      @Vancha112 2 месяца назад

      Hows the progress coming along? :)

  • @hawke1133
    @hawke1133 7 месяцев назад

    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.

    • @iced-rs
      @iced-rs  7 месяцев назад

      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.

    • @hawke1133
      @hawke1133 7 месяцев назад

      @@iced-rs My bad. I misread the code. Derp! Thought that the "text_input" was a widget in the Iced crate. Sorry.

  • @mehrnehmen
    @mehrnehmen 9 месяцев назад

    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())

    • @iced-rs
      @iced-rs  8 месяцев назад +1

      Multi-window support hasn't landed yet, but it is scheduled for the next release!

    • @mehrnehmen
      @mehrnehmen 8 месяцев назад

      I know. I meant multi screen. Different screens in one window.

  • @daodongdu3998
    @daodongdu3998 Месяц назад

    I followed the code snap and got tokio error "there is no reactor running, must be called from the context of a Tokio 1.x runtime", anyone can help me? thanks

    • @edema3763
      @edema3763 Месяц назад +1

      modify the dependencies to 'iced = {version = "0.12.1", features = ["debug", "tokio"]}'

  • @Dragon20C
    @Dragon20C 9 месяцев назад +1

    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

    • @iced-rs
      @iced-rs  9 месяцев назад +3

      Update your Rust toolchain and the issue should be fixed! Try `rustup update`.

    • @Dragon20C
      @Dragon20C 9 месяцев назад

      I see, thanks!@@iced-rs

    • @Dragon20C
      @Dragon20C 9 месяцев назад

      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

    • @iced-rs
      @iced-rs  9 месяцев назад

      @@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.

    • @Dragon20C
      @Dragon20C 9 месяцев назад

      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

  • @frankstrea2786
    @frankstrea2786 7 месяцев назад

    What linux is that

    • @iced-rs
      @iced-rs  7 месяцев назад

      Arch Linux.

  • @lareamondmobile
    @lareamondmobile 4 месяца назад +1

    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.

    • @lareamondmobile
      @lareamondmobile 4 месяца назад

      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?

    • @iced-rs
      @iced-rs  4 месяца назад +9

      @@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!