app: fix broken emoji picker

This commit is contained in:
darkfi
2025-05-04 09:49:41 +02:00
parent b8d2706a76
commit 7b6b86d5b8
5 changed files with 19 additions and 22 deletions

View File

@@ -36,7 +36,7 @@ use crate::android;
use crate::{
error::Error,
expr::Op,
gfx::{GraphicsEventPublisherPtr, RenderApi, Vertex, EpochIndex},
gfx::{EpochIndex, GraphicsEventPublisherPtr, RenderApi, Vertex},
plugin::PluginSettings,
prop::{
Property, PropertyAtomicGuard, PropertyBool, PropertyStr, PropertySubType, PropertyType,

View File

@@ -29,7 +29,7 @@ use crate::{
error::Error,
expr::{self, Compiler, Op},
gfx::{GraphicsEventPublisherPtr, Rectangle, RenderApi, Vertex},
mesh::{Color, COLOR_PURPLE, MeshBuilder},
mesh::{Color, MeshBuilder, COLOR_PURPLE},
prop::{
Property, PropertyAtomicGuard, PropertyBool, PropertyFloat32, PropertyStr, PropertySubType,
PropertyType, Role,
@@ -108,7 +108,7 @@ pub async fn make(app: &App, window: SceneNodePtr) {
expr::load_var("w"),
expr::load_var("h"),
1.,
COLOR_PURPLE
COLOR_PURPLE,
);
let node =
node.setup(|me| VectorArt::new(me, shape, app.render_api.clone(), app.ex.clone())).await;

View File

@@ -68,8 +68,8 @@ mod util;
use crate::{
app::{App, AppPtr},
net::ZeroMQAdapter,
gfx::EpochIndex,
net::ZeroMQAdapter,
prop::{
Property, PropertyAtomicGuard, PropertyBool, PropertyStr, PropertySubType, PropertyType,
Role,

View File

@@ -1267,6 +1267,15 @@ impl ChatEdit {
}
}
async fn insert(&self, txt: &str, atom: &mut PropertyAtomicGuard) {
let mut txt_ctx = text2::TEXT_CTX.get().await;
let mut editor = self.lock_editor().await;
let mut drv = editor.driver(&mut txt_ctx).await.unwrap();
drv.insert_or_replace_selection(&txt);
editor.on_buffer_changed(atom).await;
}
async fn process_insert_text_method(me: &Weak<Self>, sub: &MethodCallSub) -> bool {
let Ok(method_call) = sub.receive().await else {
debug!(target: "ui::chatedit", "Event relayer closed");
@@ -1293,7 +1302,8 @@ impl ChatEdit {
};
let atom = &mut PropertyAtomicGuard::new();
//self_.insert_text(&text, atom).await;
self_.insert(&text, atom).await;
self_.redraw().await;
true
}
@@ -1577,22 +1587,9 @@ impl UIObject for ChatEdit {
return true
}
let mut txt_ctx = text2::TEXT_CTX.get().await;
let mut editor = self.lock_editor().await;
let mut drv = editor.driver(&mut txt_ctx).await.unwrap();
t!("Key {:?} has {} actions", key, actions);
for _ in 0..actions {
let mut tmp = [0; 4];
let key_str = key.encode_utf8(&mut tmp);
drv.insert_or_replace_selection(&key_str);
}
drop(drv);
drop(txt_ctx);
editor.on_buffer_changed(atom).await;
drop(editor);
let key_str = key.to_string().repeat(actions as usize);
self.insert(&key_str, atom).await;
self.redraw().await;
true
}
@@ -1600,7 +1597,7 @@ impl UIObject for ChatEdit {
async fn handle_key_down(&self, key: KeyCode, mods: KeyMods, repeat: bool) -> bool {
t!("handle_key_down({key:?}, {mods:?}, {repeat})");
// First filter for only single digit keys
// Avoid processing events handled by insert_char()
// Avoid processing events handled by handle_char()
if !ALLOWED_KEYCODES.contains(&key) {
return false
}

View File

@@ -248,7 +248,7 @@ impl EmojiPicker {
let pos = Point::new(x, y);
let mesh = emoji_meshes.get(i);
instrs.extend_from_slice(&[
GfxDrawInstruction::Move(pos),
GfxDrawInstruction::SetPos(pos),
GfxDrawInstruction::Draw(mesh),
]);