-
Couldn't load subscription status.
- Fork 0
Update kas (master branch) #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Enter key navigation is removed (it cannot work like before).
| impl Events for Self { | ||
| type Data = (); | ||
|
|
||
| fn steal_event(&mut self, cx: &mut EventCx, _: &(), _: &Id, event: &Event) -> IsUsed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't supported any more, as such we cannot intercept the Enter key and use it to navigate down/up.
Something else is needed. Considering the hacky nature and that nothing else uses event stealing, this was not the right approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is #20.
| impl DataClerk<usize> for EntriesClerk { | ||
| type Data = ContainsCaseInsensitive; | ||
| type Key = usize; | ||
| type Item = Entry; | ||
| type Token = usize; | ||
|
|
||
| fn update(&mut self, _: &mut ConfigCx, _: Id, filter: &Self::Data) -> DataChanges { | ||
| // TODO(opt) determine when updates are a no-op and return DataChanges::None | ||
|
|
||
| self.filtered_entries = self | ||
| .entries | ||
| .iter() | ||
| .enumerate() | ||
| .filter(|(_, opt)| { | ||
| opt.as_ref() | ||
| .map(|entry| filter.matches(entry)) | ||
| .unwrap_or(false) | ||
| }) | ||
| .map(|(i, _)| i) | ||
| .collect(); | ||
|
|
||
| DataChanges::Any | ||
| } | ||
|
|
||
| fn len(&self, _: &Self::Data, _: usize) -> DataLen<usize> { | ||
| DataLen::Known(self.filtered_entries.len()) | ||
| } | ||
|
|
||
| fn update_token( | ||
| &self, | ||
| _: &Self::Data, | ||
| index: usize, | ||
| _: bool, | ||
| token: &mut Option<usize>, | ||
| ) -> TokenChanges { | ||
| let key = self.filtered_entries.get(index).cloned(); | ||
| if *token == key { | ||
| TokenChanges::None | ||
| } else { | ||
| *token = key; | ||
| TokenChanges::Any | ||
| } | ||
| } | ||
|
|
||
| fn item(&self, _: &Self::Data, key: &usize) -> &Entry { | ||
| self.entries | ||
| .get(*key) | ||
| .map(|inner| inner.as_ref()) | ||
| .flatten() | ||
| .unwrap() | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is inelegant: DataClerk is a tedious low-level interface. The higher-level DataGenerator trait doesn't seem appropriate considering we can reference entries. Not very important.
We also need to use .unwrap() in fn item since the result is no longer an Option. Missing items when a token is available is a bug, but should such a bug force a panic in user code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but should such a bug force a panic in user code?
Decision: yes. The code in map_view_widgets would need some adaptation were fn item to return an Option, and since this case is a bug, it makes little sense to adjust.
No description provided.