Skip to content

Commit

Permalink
More cargo formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
adzialocha committed Dec 10, 2024
1 parent b79f041 commit c1a76c1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 32 deletions.
34 changes: 17 additions & 17 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ use tokio::sync::{mpsc, oneshot};
use crate::config::VERSION;
use crate::glib::closure_local;
use crate::network;
use crate::AardvarkTextBuffer;
use crate::AardvarkWindow;
use crate::{AardvarkTextBuffer, AardvarkWindow};

mod imp {
use super::*;
Expand Down Expand Up @@ -66,22 +65,23 @@ mod imp {

// move the diff pointer forward to current position
doc.update_diff_cursor();

/*
let patches = doc.diff_incremental();
for patch in patches.iter() {
println!("{}", patch.action);
match &patch.action {
PatchAction::SpliceText { index: _, value: _, marks: _ } => {},
PatchAction::DeleteSeq { index: _, length: _ } => {},
PatchAction::PutMap { key: _, value: _, conflict: _ } => {},
PatchAction::PutSeq { index: _, value: _, conflict: _ } => {},
PatchAction::Insert { index: _, values: _ } => {},
PatchAction::Increment { prop: _, value: _ } => {},
PatchAction::Conflict { prop: _ } => {},
PatchAction::DeleteMap { key: _ } => {},
PatchAction::Mark { marks: _ } => {},
}
}
let patches = doc.diff_incremental();
for patch in patches.iter() {
println!("{}", patch.action);
match &patch.action {
PatchAction::SpliceText { index: _, value: _, marks: _ } => {},
PatchAction::DeleteSeq { index: _, length: _ } => {},
PatchAction::PutMap { key: _, value: _, conflict: _ } => {},
PatchAction::PutSeq { index: _, value: _, conflict: _ } => {},
PatchAction::Insert { index: _, values: _ } => {},
PatchAction::Increment { prop: _, value: _ } => {},
PatchAction::Conflict { prop: _ } => {},
PatchAction::DeleteMap { key: _ } => {},
PatchAction::Mark { marks: _ } => {},
}
}
*/

{
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ mod application;
mod config;
mod network;
mod operation;
mod window;
mod textbuffer;
mod window;

use self::application::AardvarkApplication;
use self::window::AardvarkWindow;
use self::textbuffer::AardvarkTextBuffer;
use self::window::AardvarkWindow;

use config::{GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR};
use gettextrs::{bind_textdomain_codeset, bindtextdomain, textdomain};
use gtk::{gio, glib};
use gtk::prelude::*;
use gtk::{gio, glib};

fn main() -> glib::ExitCode {
// Set up gettext translations
Expand Down
25 changes: 17 additions & 8 deletions src/textbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

use gtk::prelude::*;
use adw::subclass::prelude::*;
use gtk::glib;
use glib::subclass::Signal;
use std::sync::OnceLock;
use gtk::glib;
use gtk::prelude::*;
use std::cell::Cell;
use std::sync::OnceLock;

mod imp {
use super::*;
Expand All @@ -41,7 +41,7 @@ mod imp {
}

impl ObjectImpl for AardvarkTextBuffer {
fn signals() -> &'static [Signal] {
fn signals() -> &'static [Signal] {
static SIGNALS: OnceLock<Vec<Signal>> = OnceLock::new();
SIGNALS.get_or_init(|| {
vec![Signal::builder("text-change")
Expand All @@ -56,17 +56,24 @@ mod imp {
let offset = iter.offset();
println!("inserting new text {} at pos {}", new_text, offset);
if !self.inhibit_emit_text_change.get() {
self.obj().emit_by_name::<()>("text-change", &[&offset, &0, &new_text]);
self.obj()
.emit_by_name::<()>("text-change", &[&offset, &0, &new_text]);
}
self.parent_insert_text(iter, new_text);
}

fn delete_range(&self, start: &mut gtk::TextIter, end: &mut gtk::TextIter) {
let offset_start = start.offset();
let offset_end = end.offset();
println!("deleting range at start {} end {}", offset_start, offset_end);
println!(
"deleting range at start {} end {}",
offset_start, offset_end
);
if !self.inhibit_emit_text_change.get() {
self.obj().emit_by_name::<()>("text-change", &[&offset_start, &(offset_end - offset_start), &""]);
self.obj().emit_by_name::<()>(
"text-change",
&[&offset_start, &(offset_end - offset_start), &""],
);
}
self.parent_delete_range(start, end);
}
Expand All @@ -84,6 +91,8 @@ impl AardvarkTextBuffer {
}

pub fn set_inhibit_emit_text_change(&self, inhibit_emit_text_change: bool) {
self.imp().inhibit_emit_text_change.set(inhibit_emit_text_change);
self.imp()
.inhibit_emit_text_change
.set(inhibit_emit_text_change);
}
}
10 changes: 6 additions & 4 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

use gtk::prelude::*;
use adw::subclass::prelude::*;
use gtk::{gio, glib};
use glib::subclass::Signal;
use std::sync::OnceLock;

use adw::prelude::AdwDialogExt;
use adw::subclass::prelude::*;
use glib::subclass::Signal;
use gtk::prelude::*;
use gtk::{gio, glib};

use crate::AardvarkTextBuffer;

mod imp {
Expand Down

0 comments on commit c1a76c1

Please sign in to comment.