Comments (6)
Could you explain further? What background are you referring to?
from pound.
SetBackgroundColor struct in crossterm.
I want to display something like this
from pound.
Okay I understand.
The colors are set within the String
printed to the terminal. So you'd have to color them appropriately.
- You could create a string wrapper, similar to what I've in my tutorial.
- 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 thestr
being added. - 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. - 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.
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.
Oh so i should create a new struct that will override "EditorContents" struct?
from pound.
Not necessarily a new one. You could simply modify it to suit your needs.
from pound.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pound.