Comments (4)
For example, "3.14" is considered one word by Unicode, but the "." is considered a word splitter in Sublime.
I think Sublime gets this right: when I edit code I want to be able to select just a field's name. For instancedef
inabc.def
.
Maybe this should vary if we are editing code or just plain text, or let plugins take care of this.
from xi-editor.
Very much worth doing. The sticky point is defining word boundaries. Also note that double-clicking should select up to word boundaries, so it requires a similar primitive.
There are two tricky aspects, defining what a word boundary should be, then implementing that. I would say a good starting point for the former is UAX 29 word boundaries, but I'll also note that Sublime Text's implementation varies quite a bit from those. For example, "3.14"
is considered one word by Unicode, but the "."
is considered a word splitter in Sublime.
There's also the subtle issue that option-left-arrow tends to land after spaces after the next word boundary, but option right-arrow lands before.
UAX 29 is not trivial to implement. There's unicode_segmentation, but that implementation has two things making it not immediately usable. First, it expects the whole string, and doesn't have a way to handle partial inputs like leaves in a rope. Second, while it does have a double-ended iterator, it doesn't have a general mechanism to say, "here's an offset within a string (or, ideally, rope)", tell me (a) whether it is a boundary and (b) where the previous one is.
So a good place to start would be researching the ideal behavior. If that's UAX 29 or nearly so, then it makes sense to either improve unicode_segmentation to support xi's needs, or look at a from-scratch implementation in xi-unicode (logically it's pretty similar to line breaks, which we already do). If it's quite different from UAX 29 (and maybe in some ways simpler), then from-scratch makes more sense.
It would be possible to do something really simple as a placeholder in the meantime, like considering spaces to be word boundaries.
from xi-editor.
Under the assumption that modifying unicode_segmentation would be the way to go, how would you expect the library to handle xi-editor's custom rope implementation? A callback mechanism, where the library can continuously request 'previous' or 'next' leaves? Or develop a common interface for the class that would allow backwards/forwards movement within the rope?
Since xi-editor is already pretty unicode compliant, UAX 29 seems like a pretty decent first look. Personally, all I look for in an editor is being able to delete large token quickly, and for that case a simple space-delimited word segmented would work.
from xi-editor.
I think the best way to build the word and grapheme iterators is to have a low level struct / function that can take partial-string input. You pass in the str and a cursor location, and it either tells you the prev/next break, or returns a status code asking for more context. It worked out very nicely in xi-unicode for line break iteration, but in some ways that's a simpler problem - you only iterate forward, and you always start at a known break location, not randomly in the middle of the string. For the more general cases, you will in general need more "before" context even when going for the next break.
Given an API like that, it would be easy to wire up directly to xi-rope (or any other rope-like string store), or create a callback interface as you say.
from xi-editor.
Related Issues (20)
- bug or config error? HOT 2
- no such module 'ArgumentParser' HOT 1
- What is the state of the project ? HOT 1
- Simple `hello world` example HOT 1
- xi-core invalidates a line in the middle of the line cache
- Some cases may lead to crash when fuzzing xi-core-lib using afl.rs
- error code -32600 unknown variant `set_language` HOT 5
- Jump to next char with multiple selections HOT 1
- Is it possible to avoide Camel case to snake case in rpc.rs HOT 1
- Update crates.io versions?
- Is Xi still being maintained? HOT 1
- add `#![feature(stdsimd)]` to the crate attributes to enable HOT 2
- it can use in terminal like vim, nano ..? HOT 1
- 5ms MAX_IDLE_WAIT in xi_rpc::next_read leads to unwanted CPU utilization HOT 3
- `xi-unicode` allows linebreaks in emoji sequences
- Please remove "Xi" from name or rename to something else, this imply president's name, otherwise you'll get banned HOT 3
- [BUG REPORT] Multiple panics found in different locations. HOT 3
- [xi-core-lib] Missing panic conditon on docs
- [xi-core-lib] Arithmetic overflow occurs when using APIs HOT 1
- [xi-core-lib] Out-of-range crash occurs when using APIs
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 xi-editor.