Show current line number and total in status bar

This commit is contained in:
Timothy Warren 2019-08-29 11:47:22 -04:00
parent 172d5ad699
commit fd9f504266

View File

@ -409,15 +409,22 @@ impl Editor {
&self.filename
};
let mut message = format!("{:.20} - {} lines", filename, self.rows.len());
let mut len = message.len();
let mut left_message = format!("{:.20} - {} lines", filename, self.rows.len());
let mut right_message = format!("{}/{}", self.cursor_y + 1, self.rows.len());
let mut len = left_message.len();
let mut rlen = right_message.len();
if len > self.screen_cols {
len = self.screen_cols;
message.truncate(len);
}
self.append_out(&message);
for _ in len..self.screen_cols {
len = self.screen_cols;
left_message.truncate(len);
}
self.append_out(&left_message);
for x in len..self.screen_cols {
if self.screen_cols - x == rlen {
self.append_out(&right_message);
break;
}
self.append_out(" ");
}
self.append_out("\x1b[m");