Skip to content

Commit 9316aca

Browse files
authored
Merge branch 'master' into formatting_fix
2 parents fb9811d + 617949a commit 9316aca

File tree

7 files changed

+29
-28
lines changed

7 files changed

+29
-28
lines changed

crates/libtiny_client/src/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn tls_connector(sasl: Option<&Vec<u8>>) -> tokio_rustls::TlsConnector {
6666
.expect("Cert PEM must have at least one private key");
6767

6868
builder
69-
.with_single_cert(vec![Certificate(cert)], PrivateKey(key))
69+
.with_client_auth_cert(vec![Certificate(cert)], PrivateKey(key))
7070
.expect("Client auth cert")
7171
} else {
7272
builder.with_no_client_auth()

crates/libtiny_logger/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl LoggerInner {
193193
}
194194

195195
let mut path = self.log_dir.clone();
196-
path.push(&format!("{}.txt", serv));
196+
path.push(format!("{}.txt", serv));
197197
if let Some(mut fd) = try_open_log_file(&path, &*self.report_err) {
198198
report_io_err!(self.report_err, print_header(&mut fd));
199199
self.servers.insert(
@@ -233,7 +233,7 @@ impl LoggerInner {
233233
}
234234

235235
let mut path = self.log_dir.clone();
236-
path.push(&format!(
236+
path.push(format!(
237237
"{}_{}.txt",
238238
serv,
239239
replace_forward_slash(&chan_name_normalized)
@@ -384,7 +384,7 @@ impl LoggerInner {
384384
// can't reuse it because of borrowchk issues.
385385
let mut path = self.log_dir.clone();
386386
let chan_name_normalized = chan.normalized();
387-
path.push(&format!(
387+
path.push(format!(
388388
"{}_{}.txt",
389389
serv,
390390
replace_forward_slash(&chan_name_normalized)
@@ -414,7 +414,7 @@ impl LoggerInner {
414414
// We don't have a `new_user_tab` trait method so user log files
415415
// are created here
416416
let mut path = self.log_dir.clone();
417-
path.push(&format!("{}_{}.txt", serv, replace_forward_slash(nick)));
417+
path.push(format!("{}_{}.txt", serv, replace_forward_slash(nick)));
418418
if let Some(mut fd) = try_open_log_file(&path, &*self.report_err) {
419419
report_io_err!(self.report_err, print_header(&mut fd));
420420
f(&mut fd, &*self.report_err);

crates/libtiny_tui/src/input_area/input_line.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ impl InputLine {
3434
&self.buffer
3535
}
3636

37-
/**
38-
** Functions to interface with InputLine::buffer
39-
**/
37+
/*
38+
* Functions to interface with InputLine::buffer
39+
*/
4040

4141
/// Interface for Vec::get()
4242
pub(crate) fn get(&self, idx: usize) -> char {
@@ -77,9 +77,9 @@ impl InputLine {
7777
}
7878
}
7979

80-
/**
81-
** End of InputLine::buffer interface
82-
**/
80+
/*
81+
* End of InputLine::buffer interface
82+
*/
8383

8484
/// Calculate hedight of the widget, taking nickname length into account. Only needed when
8585
/// buffer is wider than width and scrolling is off.

crates/libtiny_tui/src/messaging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl MessagingUI {
198198
self.msg_area.resize(width, msg_area_height);
199199

200200
// We don't show the nick in exit dialogue, so it has the full width
201-
for exit_dialogue in &mut self.exit_dialogue {
201+
if let Some(exit_dialogue) = &mut self.exit_dialogue {
202202
exit_dialogue.resize(width);
203203
}
204204
}

crates/libtiny_tui/src/msg_area/line.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ impl Line {
124124
}
125125
}
126126

127-
fn add_text_inner(&mut self, str: &str) {
127+
/// Add the text to the line. The text can contain IRC formatting characters. The text should
128+
/// not contain other control characters like '\n' or '\r'.
129+
pub(crate) fn add_text(&mut self, str: &str, style: SegStyle) {
130+
self.set_message_style(style);
131+
128132
for format_event in parse_irc_formatting(str) {
129133
match format_event {
130134
IrcFormatEvent::Bold => self.add_attr(termbox_simple::TB_BOLD),
@@ -161,20 +165,16 @@ impl Line {
161165
}
162166
}
163167
}
164-
}
165168

166-
pub(crate) fn add_text(&mut self, str: &str, style: SegStyle) {
167-
self.set_message_style(style);
168-
self.add_text_inner(str)
169+
self.line_data.set_dirty();
169170
}
170171

172+
/// Add a single character to the line. The character should not be an IRC formatting character
173+
/// or other control characters like '\n' and '\r'.
171174
pub(crate) fn add_char(&mut self, char: char, style: SegStyle) {
172175
self.set_message_style(style);
173176
self.current_seg.string.push(char);
174-
}
175-
176-
pub(crate) fn force_recalculation(&mut self) {
177-
self.line_data.set_dirty()
177+
self.line_data.set_dirty();
178178
}
179179

180180
/// Calculates the number of lines that this line will be.
@@ -367,7 +367,7 @@ fn align_test() {
367367
67
368368
8
369369
*/
370-
line.add_text_inner("12345678");
370+
line.add_text("12345678", SegStyle::UserMsg);
371371

372372
assert_eq!(line.rendered_height(3), 4);
373373
}

crates/libtiny_tui/src/msg_area/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ impl MsgArea {
229229
F: Fn(&mut Line),
230230
{
231231
f(&mut self.lines[idx]);
232-
// Line was modified so we need to invalidate its height
233-
self.lines[idx].force_recalculation();
234232
}
235233

236234
pub(crate) fn clear(&mut self) {

crates/termbox/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ use unicode_width::UnicodeWidthChar;
1616
// FIXME: Use enter_ca_mode(smcup)/exit_ca_mode(rmcup) from terminfo
1717

1818
pub const TB_DEFAULT: u16 = 0x0000;
19-
pub const TB_BOLD: u16 = 0x0100;
20-
pub const TB_UNDERLINE: u16 = 0x0200;
21-
pub const TB_ITALIC: u16 = 0x0400;
22-
pub const TB_STRIKETHROUGH: u16 = 0x0800;
19+
20+
// Each attribute is a distinct bit after the low byte, so attributes can be manipulated with
21+
// bitwise operations.
22+
pub const TB_BOLD: u16 = 1 << 8;
23+
pub const TB_UNDERLINE: u16 = 1 << 9;
24+
pub const TB_ITALIC: u16 = 1 << 10;
25+
pub const TB_STRIKETHROUGH: u16 = 1 << 11;
2326

2427
pub struct Termbox {
2528
// Not available in test instances

0 commit comments

Comments
 (0)