Added status bar rpcs to send to front end#677
Conversation
aec78dd to
9cac8dc
Compare
cmyr
left a comment
There was a problem hiding this comment.
Overall looks good aside from a few little nits/documentation requests :)
| Edit { edit } => self.with_editor( | ||
| |ed, _, _| ed.apply_plugin_edit(edit)), | ||
| Alert { msg } => self.client.alert(&msg), | ||
| AddStatusItem { key, value, alignment } => self.client.add_status_item(viewID, &key, &value, &alignment), |
There was a problem hiding this comment.
Nit: I'd break these lines up by inserting a newline after the =>.
| self.peer.request_is_pending() | ||
| } | ||
|
|
||
| pub fn add_status_item(&self, key: &str, value: &str, alignment: &str) { |
There was a problem hiding this comment.
These three methods should be added to the docs, alongside the other core->frontend methods.
| } | ||
| } | ||
| self.0 += 1; | ||
| view.update_status_item("my_key", &format!("hello {}", self.0)); |
There was a problem hiding this comment.
after you get to 100 and remove "my_key", this stops doing anything. Overall I like the example, but maybe it could be tweaked a bit?
82eb0b7 to
2ccbff9
Compare
cmyr
left a comment
There was a problem hiding this comment.
This looks very close to being ready, just a few things.
|
|
||
| #### update_status_item | ||
|
|
||
| `update_status_item { key: "my_key", value: "hello"} |
| cmd: PluginNotification) { | ||
| use self::PluginNotification::*; | ||
|
|
||
| let viewID = self.view.borrow().view_id; |
There was a problem hiding this comment.
Rust convention is to give identifiers snake_case names. (You should get a warning about this when you compile; in general warnings should be addressed unless there's a good reason.)
| AddStatusItem { key, value, alignment } => | ||
| self.client.add_status_item(viewID, &key, &value, &alignment), | ||
| UpdateStatusItem { key, value } | ||
| => self.client.update_status_item(viewID, &key, &value), |
There was a problem hiding this comment.
rust style nit: the => should be on the same line as the match case; and if the statement for that case is on a newline it should be indented.
| UpdateSpans { start: usize, len: usize, spans: Vec<ScopeSpan>, rev: u64 }, | ||
| Edit { edit: PluginEdit }, | ||
| Alert { msg: String }, | ||
| AddStatusItem { key: String, value: String, alignment: String }, |
There was a problem hiding this comment.
There's an argument that there should be a new Alignment type used here, but I don't think that needs to be blocking.
| /// and the user inserts an exclamation mark, the plugin will capitalize the | ||
| /// preceding word. | ||
| struct SamplePlugin; | ||
| struct SamplePlugin(usize); |
There was a problem hiding this comment.
I'm not sure I'd like to include this update to the sample plugin in this PR. I'm not exactly sure what the role of the sample-plugin project is, and I do imagine updating that project to show examples of various plugin features, but this particular addition doesn't feel like it is a very useful illustration.
What might make the most sense for things like this, where we want some simple plugin just to demo a new feature, would be to copy sample-plugin into a new folder (out side of xi-editor) and then make a new repo for your new example, put that on your github, or something like this?
542b9ea to
9ad5c2c
Compare
9ad5c2c to
4b4bb48
Compare
…l changes in sample plugin
4b4bb48 to
1d318ba
Compare
|
Thanks! |
This PR is a companion PR to xi-mac's #183. This PR adds necessary RPC items and commands to support status bar items, along with a sample plugin that makes use of these features.