mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-08 22:28:12 -05:00
app: fix android build errors due to recent changes
This commit is contained in:
@@ -143,7 +143,7 @@ impl Editor {
|
||||
let select = parley::Selection::word_from_point(&self.layout, pos.x, pos.y);
|
||||
assert!(!select.is_collapsed());
|
||||
let select = select.text_range();
|
||||
self.set_selection(select.start, select.end).await;
|
||||
self.set_selection(select.start, select.end);
|
||||
}
|
||||
|
||||
pub fn get_cursor_pos(&self) -> Point {
|
||||
@@ -171,7 +171,7 @@ impl Editor {
|
||||
self.state.select = (cursor_idx, cursor_idx);
|
||||
self.state.compose = None;
|
||||
self.input.set_state(self.state.clone());
|
||||
self.on_buffer_changed(atom).await;
|
||||
self.on_buffer_changed(atom);
|
||||
}
|
||||
|
||||
pub fn driver(&mut self) -> ParleyDriverWrapper {
|
||||
|
||||
@@ -16,12 +16,21 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::mesh::Color;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
use crate::{mesh::Color, text};
|
||||
use crate::text;
|
||||
|
||||
pub struct ParleyDriverWrapper<'a> {
|
||||
#[cfg(not(target_os = "android"))]
|
||||
editor: &'a mut parley::PlainEditor<Color>,
|
||||
|
||||
/// Needed or we get a stupid error about unused lifetime.
|
||||
/// This is zerocost anyway.
|
||||
#[cfg(target_os = "android")]
|
||||
_phantom: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
impl<'a> ParleyDriverWrapper<'a> {
|
||||
@@ -32,7 +41,7 @@ impl<'a> ParleyDriverWrapper<'a> {
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn new(_layout: &mut parley::Layout<Color>) -> Self {
|
||||
Self {}
|
||||
Self { _phantom: PhantomData }
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
|
||||
@@ -1273,14 +1273,18 @@ impl BaseEdit {
|
||||
t!("handle_android_event({state:?})");
|
||||
let atom = &mut self.render_api.make_guard(gfxtag!("BaseEdit::handle_android_event"));
|
||||
|
||||
let mut editor = self.editor.lock();
|
||||
// Diff old and new state so we know what changed
|
||||
let is_text_changed = editor.state.text != state.text;
|
||||
let is_select_changed = editor.state.select != state.select;
|
||||
let is_compose_changed = editor.state.compose != state.compose;
|
||||
editor.state = state;
|
||||
editor.on_buffer_changed(atom).await;
|
||||
drop(editor);
|
||||
let (is_text_changed, is_select_changed, is_compose_changed) = {
|
||||
let mut editor = self.editor.lock();
|
||||
// Diff old and new state so we know what changed
|
||||
let diff = (
|
||||
editor.state.text != state.text,
|
||||
editor.state.select != state.select,
|
||||
editor.state.compose != state.compose,
|
||||
);
|
||||
editor.state = state;
|
||||
editor.on_buffer_changed(atom);
|
||||
diff
|
||||
};
|
||||
|
||||
// Nothing changed. Just return.
|
||||
if !is_text_changed && !is_select_changed && !is_compose_changed {
|
||||
@@ -1297,6 +1301,8 @@ impl BaseEdit {
|
||||
|
||||
// Not sure what to do if only compose changes lol
|
||||
// For now just ignore it.
|
||||
// Changing the cursor pos will change the compose state if a word is edited.
|
||||
// However making selection has a tendency to send spurious compose events.
|
||||
|
||||
// Text changed - finish any active selection
|
||||
if is_text_changed {
|
||||
@@ -1479,7 +1485,7 @@ impl UIObject for BaseEdit {
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
let recvr = self.lock_editor().await.recvr.clone();
|
||||
let recvr = self.editor.lock().recvr.clone();
|
||||
let me2 = me.clone();
|
||||
let autosuggest_task = ex.spawn(async move {
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user