Skip to content

Commit

Permalink
Fix clippy lints, run rustfmt
Browse files Browse the repository at this point in the history
Signed-off-by: Manos Pitsidianakis <[email protected]>
  • Loading branch information
epilys committed Nov 15, 2024
1 parent a584fb9 commit 2dacc2e
Show file tree
Hide file tree
Showing 20 changed files with 2,804 additions and 2,330 deletions.
16 changes: 9 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const LINE_BREAK_TABLE_URL: &str = "http://www.unicode.org/Public/UCD/latest/ucd/LineBreak.txt";
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::PathBuf;
use std::process::Command;
use std::{
fs::File,
io::{prelude::*, BufReader},
path::PathBuf,
process::Command,
};

include!("src/text_processing/types.rs");

Expand All @@ -23,7 +24,7 @@ fn main() -> Result<(), std::io::Error> {
);
tmpdir_path.push("LineBreak.txt");
Command::new("curl")
.args(&["-o", tmpdir_path.to_str().unwrap(), LINE_BREAK_TABLE_URL])
.args(["-o", tmpdir_path.to_str().unwrap(), LINE_BREAK_TABLE_URL])
.output()?;

let file = File::open(&tmpdir_path)?;
Expand All @@ -38,7 +39,8 @@ fn main() -> Result<(), std::io::Error> {
let tokens: &str = line.split_whitespace().next().unwrap();

let semicolon_idx: usize = tokens.chars().position(|c| c == ';').unwrap();
/* LineBreak.txt list is ascii encoded so we can assume each char takes one byte: */
// LineBreak.txt list is ascii encoded so we can assume each char takes one
// byte:
let chars_str: &str = &tokens[..semicolon_idx];

let mut codepoint_iter = chars_str.split("..");
Expand Down
8 changes: 8 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
edition = "2018"
format_generated_files = false
format_code_in_doc_comments = true
format_strings = true
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
wrap_comments = true
normalize_comments = true
78 changes: 37 additions & 41 deletions src/components.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
/*
* bb
*
* Copyright 2019 Manos Pitsidianakis
*
* This file is part of bb.
*
* bb is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* bb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bb. If not, see <http://www.gnu.org/licenses/>.
*/
// bb
//
// Copyright 2019 Manos Pitsidianakis
//
// This file is part of bb.
//
// bb is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// bb is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with bb. If not, see <http://www.gnu.org/licenses/>.

/*!
Components are ways to handle application data. They can draw on the terminal and receive events, but also do other stuff as well. (For example, see the `notifications` module.)
//! Components are ways to handle application data. They can draw on the
//! terminal and receive events, but also do other stuff as well. (For example,
//! see the `notifications` module.)
//!
//! See the `Component` Trait for more details.
See the `Component` Trait for more details.
*/

use crate::state::*;
use crate::terminal::*;
use crate::{state::*, terminal::*};
mod utilities;
pub use utilities::*;

mod kernel;
pub use kernel::*;
pub mod processes;
pub use processes::*;
use std::{
collections::{HashMap, VecDeque},
fmt,
fmt::{Debug, Display},
};

use std::collections::{HashMap, VecDeque};
use std::fmt;
use std::fmt::{Debug, Display};
pub use processes::*;

use super::{Key, UIEvent};
// The upper and lower boundary char. const HORZ_BOUNDARY: char = '─';
Expand All @@ -47,8 +46,6 @@ pub type ShortcutMap = HashMap<&'static str, Key>;
pub type ShortcutMaps = HashMap<String, ShortcutMap>;

/// Types implementing this Trait can draw on the terminal and receive events.
/// If a type wants to skip drawing if it has not changed anything, it can hold some flag in its
/// fields (eg self.dirty = false) and act upon that in their `draw` implementation.
pub trait Component: Display + Debug + Send {
fn draw(
&mut self,
Expand All @@ -74,16 +71,15 @@ pub fn create_box(grid: &mut CellBuffer, area: Area) {
let upper_left = upper_left!(area);
let bottom_right = bottom_right!(area);

/*for x in get_x(upper_left)..=get_x(bottom_right) {
grid[(x, get_y(upper_left))].set_ch(HORZ_BOUNDARY);
grid[(x, get_y(bottom_right))].set_ch(HORZ_BOUNDARY);
grid[(x, get_y(bottom_right))].set_ch('▒');
grid[(x, get_y(bottom_right))].set_fg(Color::Byte(240));
}
*/
// for x in get_x(upper_left)..=get_x(bottom_right) {
// grid[(x, get_y(upper_left))].set_ch(HORZ_BOUNDARY);
// grid[(x, get_y(bottom_right))].set_ch(HORZ_BOUNDARY);
// grid[(x, get_y(bottom_right))].set_ch('▒');
// grid[(x, get_y(bottom_right))].set_fg(Color::Byte(240));
// }

for y in get_y(upper_left)..=get_y(bottom_right) {
//grid[(get_x(upper_left), y)].set_ch(VERT_BOUNDARY);
// grid[(get_x(upper_left), y)].set_ch(VERT_BOUNDARY);
grid[(get_x(bottom_right), y)]
.set_ch('▒')
.set_fg(Color::Byte(240));
Expand Down
Loading

0 comments on commit 2dacc2e

Please sign in to comment.