Giter Club home page Giter Club logo

Comments (6)

Kofituo avatar Kofituo commented on August 25, 2024

Could you explain further? What background are you referring to?

from pound.

Chaos4U avatar Chaos4U commented on August 25, 2024

SetBackgroundColor struct in crossterm.
I want to display something like this

  1. To create some autocomplete functionality.
    preview

  2. Or some mini window like this
    To create many stuff like file explorer, find file, etc.
    preview_two

from pound.

Kofituo avatar Kofituo commented on August 25, 2024

Okay I understand.

The colors are set within the String printed to the terminal. So you'd have to color them appropriately.

  1. You could create a string wrapper, similar to what I've in my tutorial.
  2. Create a push / push_str functions and then check if the new string being added falls with the specified range. You could simply do so by checking the len of the str being added.
  3. If it falls within your specified range, first add SetBackgroundColor(color) to your string. Next add the range of the string you want to color. Reset set the background color. And then add the remaining range.
  4. Alternatively, since you want to color a fixed range, a more convenient option maybe to modify your output string just before you write it to the terminal. In this method, you do not need to create a new type: Add SetBackgroundColor(color) before your start index, then reset background color after your end index. Since this method inserts randomly into a string, it might be slightly slower than the former method. However that should be a concern if only you experience lag. I don't think you'll though. Rust is really fast.

from pound.

Kofituo avatar Kofituo commented on August 25, 2024

However, depending on your program, the implementation might be slightly different. If you understand the principle I just gave, you'd be able to do it!

from pound.

Chaos4U avatar Chaos4U commented on August 25, 2024

Oh so i should create a new struct that will override "EditorContents" struct?

from pound.

Kofituo avatar Kofituo commented on August 25, 2024

Not necessarily a new one. You could simply modify it to suit your needs.

from pound.

Related Issues (1)

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.