@@ -34,6 +34,8 @@ type Terminal = tui::Terminal<CrosstermBackend<std::io::Stdout>>;
35static EX: smol::Executor = smol::Executor::new();
35static EX: smol::Executor = smol::Executor::new();
37+const BASE_WIDTH: u16 = 30;
37pub struct Application {
39pub struct Application {
38 editor: Editor,
40 editor: Editor,
39 prompt: Option<Prompt>,
41 prompt: Option<Prompt>,
@@ -253,9 +255,10 @@ impl Renderer {
254 let mut row = 0;
256 let mut row = 0;
255 let mut col = 0;
257 let mut col = 0;
258+ let max_row: u16 = self.size.0 / BASE_WIDTH;
256 // TODO: this will crash if there are too many cols added
259 // TODO: this will crash if there are too many cols added
257 // TODO: set char limit
260 // TODO: set char limit
258− for i in (0..completion.len()) {
261+ for (i, command) in completion.iter().enumerate() {
259 let color = if prompt.completion_selection_index.is_some()
262 let color = if prompt.completion_selection_index.is_some()
260 && i == prompt.completion_selection_index.unwrap()
263 && i == prompt.completion_selection_index.unwrap()
@@ -263,16 +266,20 @@ impl Renderer {
264 self.text_color
267 self.text_color
266− self.surface.set_string(
269+ self.surface.set_stringn(
267− 1 + col * 10,
270+ 1 + row * BASE_WIDTH,
268− self.size.1 - 6 + row as u16,
271+ self.size.1 - 6 + col as u16,
269− &completion[i],
272+ &command,
273+ BASE_WIDTH as usize - 1,
272− row += 1;
276+ col += 1;
273− if row > 3 {
277+ if col > 3 {
274− row = 0;
278+ col = 0;
275− col += 1;
279+ row += 1;
@@ -436,6 +443,31 @@ impl Application {
436 String::from("ccc"),
443 String::from("ccc"),
437 String::from("ddd"),
444 String::from("ddd"),
438 String::from("eee"),
445 String::from("eee"),
446+ String::from("averylongcommandaverylongcommandaverylongcommandaverylongcommandaverylongcommand"),
448+ String::from("aaa"),
449+ String::from("bbb"),
450+ String::from("ccc"),
451+ String::from("ddd"),
452+ String::from("eee"),
454+ String::from("aaa"),
455+ String::from("bbb"),
456+ String::from("ccc"),
457+ String::from("ddd"),
458+ String::from("eee"),
460+ String::from("aaa"),
461+ String::from("bbb"),
462+ String::from("ccc"),
463+ String::from("ddd"),
464+ String::from("eee"),
466+ String::from("aaa"),
467+ String::from("bbb"),
468+ String::from("ccc"),
469+ String::from("ddd"),
470+ String::from("eee"),
440 for command in command_list {
472 for command in command_list {
441 if command.contains(_input) {
473 if command.contains(_input) {