I forget, what I changes

This commit is contained in:
doryan 2024-02-22 19:57:12 +04:00
parent 703292a799
commit db1de143d3
4 changed files with 139 additions and 125 deletions

View File

@ -1,8 +1,11 @@
use gtk4 as gtk; use gtk4 as gtk;
use gtk::*; use gtk::*;
use view::*;
use gtk::prelude::*; use gtk::prelude::*;
use crate::view::ui::ui;
#[path="utils/parsing_vector.rs"]
mod parsing;
#[path="ui_src/components/switch.rs"] #[path="ui_src/components/switch.rs"]
mod switch; mod switch;

View File

@ -8,6 +8,7 @@
pub mod hamming_code{ pub mod hamming_code{
use std::collections::HashMap; use std::collections::HashMap;
use crate::parsing::parsing::parse;
pub fn hamming_encrypt_data(data: &Vec<u8>, result_string: &mut String, length_of_code: usize) -> () { pub fn hamming_encrypt_data(data: &Vec<u8>, result_string: &mut String, length_of_code: usize) -> () {
let mut i : usize = length_of_code; let mut i : usize = length_of_code;
@ -81,11 +82,15 @@ pub mod hamming_code{
} }
}).collect(); }).collect();
let errored_code = parse(data_bits);
let correct_code = parse(correctly_code.as_slice());
let error = format!("Ошибка в коде {} {:?}, позиция ошибки {}, корректный код: {:?}; \n", let error = format!("Ошибка в коде {} {:?}, позиция ошибки {}, корректный код: {:?}; \n",
i / 7, i / 7,
&data_bits, errored_code,
error_position, error_position,
correctly_code correct_code
); );
errors.push_str(error.as_str()); errors.push_str(error.as_str());

View File

@ -0,0 +1,9 @@
pub mod parsing{
pub fn parse(slice : &[u8]) -> String {
slice
.iter()
.map(|bit| bit.to_string())
.reduce(|accumulator, element| accumulator + &*element)
.unwrap()
}
}

View File

@ -1,17 +1,13 @@
pub mod ui {
use gtk4 as gtk; use gtk4 as gtk;
use gtk::*; use gtk::*;
use gtk::prelude::*; use gtk::prelude::*;
use super::wrapper::*; use crate::controller::{BtnEventHandler, EventHandler, SwEventHandler};
use super::controller::*; use crate::parse_input::parse_input;
use super::parse_input::parse_input; use crate::properties::{Alignment, MarginData, Setters, TextViewSetters};
use super::state_controller::state_controller; use crate::state_controller::state_controller;
use super::properties::{MarginData, Setters, TextViewSetters, Alignment}; use crate::wrapper::Wrapper;
fn clearing(output : &TextView, input: &TextView){
input.buffer().set_text("");
output.buffer().set_text("");
}
pub fn laboratory_work_first_section(wrapper: &Box) -> (){ pub fn laboratory_work_first_section(wrapper: &Box) -> (){
@ -147,7 +143,7 @@ pub fn ui(application: &Application) {
let window = ApplicationWindow::builder() let window = ApplicationWindow::builder()
.title("Комплексная программа для лаб. работ") .title("Комплексная программа для лаб. работ")
.width_request(650) .width_request(800)
.height_request(400) .height_request(400)
.application(application) .application(application)
.child(&mutual_wrapper) .child(&mutual_wrapper)
@ -155,3 +151,4 @@ pub fn ui(application: &Application) {
window.show(); window.show();
} }
}