Comments (5)
Yeah, if you open view.rs
too you'll see there's a funny character in there →
which gets displayed all wrong. Something needs to be added which will do some checking on special characters like this before drawing them with rustbox
. I haven't spent a whole lot of time investigating Ascii characters with Rust just yet, so I'm not sure what exactly I need to do to make this work. If anyone has any pointers I'd love to hear them!
from iota.
I experimented a little and made a short patch that fixed this. I guess I should submit a PR? Edit: It’s actually looking a little trickier than I thought. I wonder if making Line
store a String
instead of a Vec<u8>
would be a reasonable solution?
from iota.
Yep, PRs are more than welcome!
I actually used to have Line
store a String
though I moved away from it as I thought Vec<u8>
was more sensible and more efficient. I'm open to being convinced otherwise, though. What benefits are you seeing with using String instead of the vec?
from iota.
String
enforces that its contents are valid UTF-8, and is designed to work with characters rather than bytes. This is both a good and a bad thing: it’s good because you get methods for working with characters instead of bytes, which is what you normally want when showing/editing text, but it’s bad because if you get something that isn’t valid UTF-8, you’re going to have a hard time using something that cannot be safely constructed or used when it contains invalid UTF-8. Rendering invalid characters on a terminal doesn’t really make any sense anyway, but it could be useful to show some kind of replacement instead, and using String
might somehow complicate that. I personally think it’s fine to start with only basic UTF-8 support, and then later (if it has the demand) move on to support for invalid UTF-8 and even other encodings.
String
shouldn’t be any less efficient as far as I know: it’s internally represented as a Vec<u8>
. I guess some things like character indexing and character length are O(n) instead of O(1), but I personally think that correctness is more important than a slight speed boost in this case, and the performance shouldn’t be affected too much since it’s on a per-line basis (and lines aren’t usually that long).
from iota.
Ok, these are some good points. This is definitely worth looking into. Shouldn't be a huge task in converting to use String
. I'll give it a go and see if it solves our problem.
from iota.
Related Issues (20)
- panic during save if the cmd line argument is a dir
- Go to line cmd
- Make commands chainable HOT 2
- Some system of hints
- No way to add a new line HOT 1
- Syntax highlighting improvements HOT 2
- Crash in Vi mode after pressing 'a' followed by 'w' HOT 3
- (Vi mode) Crash on relative cursor move
- where is binary release? how to install? HOT 5
- Goto Anything HOT 4
- Move to start of line not working properly HOT 2
- Can't exit from editor (started with no name)
- Spanish translation
- Add Json support for keybindings, to add own keybindings HOT 1
- Implement LSP HOT 1
- Update rustc-serialize with serde
- Marks & MarkPosition and how are they kept valid?
- How to quit when run without filename HOT 1
- termbox HOT 1
- Activity? Still maintained? HOT 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 iota.