Skip to content

Commit

Permalink
Merge branch 'master' into formatting_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
osa1 authored Sep 23, 2024
2 parents fb9811d + 617949a commit 9316aca
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion crates/libtiny_client/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn tls_connector(sasl: Option<&Vec<u8>>) -> tokio_rustls::TlsConnector {
.expect("Cert PEM must have at least one private key");

builder
.with_single_cert(vec![Certificate(cert)], PrivateKey(key))
.with_client_auth_cert(vec![Certificate(cert)], PrivateKey(key))
.expect("Client auth cert")
} else {
builder.with_no_client_auth()
Expand Down
8 changes: 4 additions & 4 deletions crates/libtiny_logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl LoggerInner {
}

let mut path = self.log_dir.clone();
path.push(&format!("{}.txt", serv));
path.push(format!("{}.txt", serv));
if let Some(mut fd) = try_open_log_file(&path, &*self.report_err) {
report_io_err!(self.report_err, print_header(&mut fd));
self.servers.insert(
Expand Down Expand Up @@ -233,7 +233,7 @@ impl LoggerInner {
}

let mut path = self.log_dir.clone();
path.push(&format!(
path.push(format!(
"{}_{}.txt",
serv,
replace_forward_slash(&chan_name_normalized)
Expand Down Expand Up @@ -384,7 +384,7 @@ impl LoggerInner {
// can't reuse it because of borrowchk issues.
let mut path = self.log_dir.clone();
let chan_name_normalized = chan.normalized();
path.push(&format!(
path.push(format!(
"{}_{}.txt",
serv,
replace_forward_slash(&chan_name_normalized)
Expand Down Expand Up @@ -414,7 +414,7 @@ impl LoggerInner {
// We don't have a `new_user_tab` trait method so user log files
// are created here
let mut path = self.log_dir.clone();
path.push(&format!("{}_{}.txt", serv, replace_forward_slash(nick)));
path.push(format!("{}_{}.txt", serv, replace_forward_slash(nick)));
if let Some(mut fd) = try_open_log_file(&path, &*self.report_err) {
report_io_err!(self.report_err, print_header(&mut fd));
f(&mut fd, &*self.report_err);
Expand Down
12 changes: 6 additions & 6 deletions crates/libtiny_tui/src/input_area/input_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ impl InputLine {
&self.buffer
}

/**
** Functions to interface with InputLine::buffer
**/
/*
* Functions to interface with InputLine::buffer
*/

/// Interface for Vec::get()
pub(crate) fn get(&self, idx: usize) -> char {
Expand Down Expand Up @@ -77,9 +77,9 @@ impl InputLine {
}
}

/**
** End of InputLine::buffer interface
**/
/*
* End of InputLine::buffer interface
*/

/// Calculate hedight of the widget, taking nickname length into account. Only needed when
/// buffer is wider than width and scrolling is off.
Expand Down
2 changes: 1 addition & 1 deletion crates/libtiny_tui/src/messaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl MessagingUI {
self.msg_area.resize(width, msg_area_height);

// We don't show the nick in exit dialogue, so it has the full width
for exit_dialogue in &mut self.exit_dialogue {
if let Some(exit_dialogue) = &mut self.exit_dialogue {
exit_dialogue.resize(width);
}
}
Expand Down
20 changes: 10 additions & 10 deletions crates/libtiny_tui/src/msg_area/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ impl Line {
}
}

fn add_text_inner(&mut self, str: &str) {
/// Add the text to the line. The text can contain IRC formatting characters. The text should
/// not contain other control characters like '\n' or '\r'.
pub(crate) fn add_text(&mut self, str: &str, style: SegStyle) {
self.set_message_style(style);

for format_event in parse_irc_formatting(str) {
match format_event {
IrcFormatEvent::Bold => self.add_attr(termbox_simple::TB_BOLD),
Expand Down Expand Up @@ -161,20 +165,16 @@ impl Line {
}
}
}
}

pub(crate) fn add_text(&mut self, str: &str, style: SegStyle) {
self.set_message_style(style);
self.add_text_inner(str)
self.line_data.set_dirty();
}

/// Add a single character to the line. The character should not be an IRC formatting character
/// or other control characters like '\n' and '\r'.
pub(crate) fn add_char(&mut self, char: char, style: SegStyle) {
self.set_message_style(style);
self.current_seg.string.push(char);
}

pub(crate) fn force_recalculation(&mut self) {
self.line_data.set_dirty()
self.line_data.set_dirty();
}

/// Calculates the number of lines that this line will be.
Expand Down Expand Up @@ -367,7 +367,7 @@ fn align_test() {
67
8
*/
line.add_text_inner("12345678");
line.add_text("12345678", SegStyle::UserMsg);

assert_eq!(line.rendered_height(3), 4);
}
2 changes: 0 additions & 2 deletions crates/libtiny_tui/src/msg_area/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ impl MsgArea {
F: Fn(&mut Line),
{
f(&mut self.lines[idx]);
// Line was modified so we need to invalidate its height
self.lines[idx].force_recalculation();
}

pub(crate) fn clear(&mut self) {
Expand Down
11 changes: 7 additions & 4 deletions crates/termbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ use unicode_width::UnicodeWidthChar;
// FIXME: Use enter_ca_mode(smcup)/exit_ca_mode(rmcup) from terminfo

pub const TB_DEFAULT: u16 = 0x0000;
pub const TB_BOLD: u16 = 0x0100;
pub const TB_UNDERLINE: u16 = 0x0200;
pub const TB_ITALIC: u16 = 0x0400;
pub const TB_STRIKETHROUGH: u16 = 0x0800;

// Each attribute is a distinct bit after the low byte, so attributes can be manipulated with
// bitwise operations.
pub const TB_BOLD: u16 = 1 << 8;
pub const TB_UNDERLINE: u16 = 1 << 9;
pub const TB_ITALIC: u16 = 1 << 10;
pub const TB_STRIKETHROUGH: u16 = 1 << 11;

pub struct Termbox {
// Not available in test instances
Expand Down

0 comments on commit 9316aca

Please sign in to comment.