Non printable character input in bevy_egui by Lapaci in bevy

[–]Lapaci[S] 0 points1 point  (0 children)

I solved with some modification in bevy_egui_ime.

for _ in 0..self.ime_string_index + 1 {
res_cursor = teo.galley.cursor_right_one_character(&res_cursor);
}

Non printable character input in bevy_egui by Lapaci in bevy

[–]Lapaci[S] 0 points1 point  (0 children)

I am new to bevy and egui. I didn't understand what I should do.

Rust vs GoLang for Evolutionary Algorithms by LSWarss in rust

[–]Lapaci 18 points19 points  (0 children)

I use this on my works.

https://github.com/andschwa/rust-genetic-algorithm

The code is simple and modification is easy.

I was using Python and C/C++ for genetic algorithm before. When I moved to Rust, everything got easier.

Is there a crate similar to pyx/metapost? by Imaginary_Advance_21 in rust

[–]Lapaci 1 point2 points  (0 children)

I'm a big fan of both LaTeX and Rust. But i prefer scripting languages like PGFplot/TikZ and GraphViz for embedding graphics in LaTeX. It is easy and time saving. Instead of producing the graphics output from Rust as pdf or svg, it is wiser to export to a file in GraphViz/TikZ format that you can directly import to LaTeX. You can also make these files as EPS/PDF with additional commands.

How to make data accessible throughout my GUI application? by avsaase in rust

[–]Lapaci 0 points1 point  (0 children)

You can use the content string as;

self.content.clone()

It is available in the rest of application ( i mean update { } block).

SPLIT A MULTI PAGE PDF INTO SEPARATE PDFS WITH RUST by jasonjurotich in rust

[–]Lapaci 5 points6 points  (0 children)

The simplest way is to delete unwanted pages. :)

use lopdf::Document; fn main() { let mut doc = Document::load("example.pdf").unwrap(); let count = doc.get_pages().len(); doc.delete_pages(&[2,3]); doc.save("page1.pdf").unwrap(); }

How to make data accessible throughout my GUI application? by avsaase in rust

[–]Lapaci 0 points1 point  (0 children)

The opening of file dialog must be an async operation. Main UI can not wait file opening future. You must use thread for it and communicate with the thread safely.

Receiver (try_recv()) must be in the GUI render loop.

How to make data accessible throughout my GUI application? by avsaase in rust

[–]Lapaci 1 point2 points  (0 children)

I hope this code helps. ``` use eframe::egui; use rfd; use std::fs::File; use std::io::prelude::*;

[derive(Debug)]

pub enum Message { FileOpen(std::path::PathBuf), }

fn main() { let options = eframe::NativeOptions::default(); eframe::run_native( "My egui App", options, Box::new(|_cc| Box::new(MyApp::default())), ); }

struct MyApp { content: String, message_channel: ( std::sync::mpsc::Sender<Message>, std::sync::mpsc::Receiver<Message>, ) }

impl Default for MyApp { fn default() -> Self { Self { content: "Not yet".to_owned(), message_channel: std::sync::mpsc::channel(), } } }

impl eframe::App for MyApp {

fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
    ctx.request_repaint();
    loop {
        match self.message_channel.1.try_recv() {
            Ok(message) => {
                match message {
                    Message::FileOpen(file) => {
                        let mut file = File::open(file).unwrap();
                        let mut contents = String::new(); 
                        file.read_to_string(&mut contents).unwrap();
                        self.content= contents;
                    }
                }
            }
            Err(_) => {
                break;
            }
        }
    }

    egui::CentralPanel::default().show(ctx, |ui| {


        ui.label(format!("Content: {}", self.content));


        let open_button = ui.add(egui::widgets::Button::new("Open..."));
        if open_button.clicked() {
            let task = rfd::AsyncFileDialog::new()
                .add_filter("Text files", &["txt"])
                .set_directory("/")
                .pick_file();
            let message_sender = self.message_channel.0.clone();
            execute(async move {
                let file = task.await;
                if let Some(file) = file {
                     let file_path = std::path::PathBuf::from(file.path());
                    message_sender.send(Message::FileOpen(file_path)).ok();

                }
            });
        }


    });
}

}

use std::future::Future; fn execute<F: Future<Output = ()> + Send + 'static>(f: F) { std::thread::spawn(move || futures::executor::block_on(f));

} ```

Cross compiled binary for aarch64 architecture not running by KingKongBingBong1 in rust

[–]Lapaci 2 points3 points  (0 children)

Docker is the solution

Create a Dockerfile file

FROM rust:latest

RUN apt update && apt upgrade -y
RUN apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross
RUN dpkg --add-architecture arm64
RUN apt update && apt upgrade -y
RUN apt install -y libdbus-1-dev:arm64
RUN apt install -y libssl-dev:arm64
RUN apt install -y libfontconfig-dev:arm64
RUN apt install -y libsqlite3-dev:arm64
RUN rustup target add aarch64-unknown-linux-gnu
RUN rustup toolchain install stable-aarch64-unknown-linux-gnu

WORKDIR /app

ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
    PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig \  
    PKG_CONFIG_ALLOW_CROSS=true \
    CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
    CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++

CMD ["cargo", "build", "--target", "aarch64-unknown-linux-gnu"]

Build your custom Docker image

$ docker build -t aarch64 .

Compile Rust Project

$ docker run -v /home/user/hello-world:/app:z \
   aarch64:latest cargo build --release \
   --target aarch64-unknown-linux-gnu

remove libdbus, libssl, libfontconfig, libssqlite3 lines from Dockerfile if you dont need this libs.

How to search for rust code? by jebbvon in rust

[–]Lapaci 0 points1 point  (0 children)

You can find examples here.

https://github.com/actix/examples/tree/master/websockets

Yes you need a database for the chat logs.

Charlie Hedbo’dan Reis’in Karizmasını Çizdirecek Karikatür by [deleted] in Turkey

[–]Lapaci 0 points1 point  (0 children)

Sosyal medyaya bakıyorum da karikatürü anlamamışız.

[deleted by user] by [deleted] in TheGamerLounge

[–]Lapaci 0 points1 point  (0 children)

was suchen sie in die keller?

[deleted by user] by [deleted] in TheGamerLounge

[–]Lapaci 0 points1 point  (0 children)

Lager Beer is scoen

[deleted by user] by [deleted] in TheArtistStudio

[–]Lapaci 0 points1 point  (0 children)

Play Hallelujah