lunar-mining 4 роки тому
батько
коміт
ffd9c8e185
2 змінених файлів з 37 додано та 17 видалено
  1. 1 1
      bin/map/Cargo.toml
  2. 36 16
      bin/map/src/main.rs

+ 1 - 1
bin/map/Cargo.toml

@@ -4,7 +4,7 @@ version = "0.1.0"
 edition = "2021"
 
 [dependencies]
-darkfi = { path = "../../" , features = ['tui']}
+#darkfi = { path = "../../" , features = ['tui']}
 smol = "1.2.5"
 tui = "0.16.0"
 termion = "1.5"

+ 36 - 16
bin/map/src/main.rs

@@ -1,16 +1,18 @@
-use drk::Result;
+// make async task that updates info
+// this display that
+//use drk::Result;
 use std::{io, io::Read};
 use termion::{async_stdin, event::Key, input::TermRead, raw::IntoRawMode};
 use tui::{
     backend::TermionBackend,
     layout::{Constraint, Direction, Layout},
     style::{Color, Modifier, Style},
-    text::Spans,
-    widgets::{Block, Borders, List, ListItem, Paragraph},
+    text::{Span, Spans, Text},
+    widgets::{ListState, Block, Borders, List, ListItem, Paragraph, Wrap},
     Terminal,
 };
 
-fn main() -> Result<()> {
+fn main() -> Result<(), io::Error> {
     // Set up terminal output
     let stdout = io::stdout().into_raw_mode()?;
     let backend = TermionBackend::new(stdout);
@@ -38,7 +40,7 @@ fn main() -> Result<()> {
             // Create a paragraph with the above text...
             let graph = Paragraph::new(txt)
                 // In a block with borders and the given title...
-                .block(Block::default().title("List of active nodes").borders(Borders::ALL))
+                .block(Block::default().title("").borders(Borders::ALL))
                 // With white foreground and black background...
                 .style(Style::default().fg(Color::White).bg(Color::Black));
 
@@ -46,20 +48,36 @@ fn main() -> Result<()> {
             frame.render_widget(graph, chunks[0]);
 
             // create a list
-            let mut items: Vec<ListItem> = Vec::new();
-            for num in 1..100 {
-                let new_item = ListItem::new(format!("Node {}", num));
-                items.push(new_item);
+            //let mut items: Vec<ListItem> = Vec::new();
+            //for num in 1..100 {
+            //    let new_item = ListItem::new(format!("Node {}", num));
+            //    items.push(new_item);
+            //}
+
+            //let list = List::new(items)
+            //    .block(Block::default().title("Nodes").borders(Borders::ALL))
+            //    .style(Style::default().fg(Color::White))
+            //    .highlight_style(Style::default().add_modifier(Modifier::ITALIC))
+            //    .highlight_symbol(">>");
+
+            //// draw a list
+            //frame.render_widget(list, chunks[1]);
+
+            // make a paragraph
+            let mut text1 = String::new();
+            for num in 1..10000 {
+                let text2 = format!("\n Node {}\n", num);
+                text1.push_str(&text2);
             }
 
-            let list = List::new(items)
-                .block(Block::default().title("Nodes").borders(Borders::ALL))
-                .style(Style::default().fg(Color::White))
-                .highlight_style(Style::default().add_modifier(Modifier::ITALIC))
-                .highlight_symbol(">>");
+            let text = Spans::from(vec![Span::raw(String::from(text1))]);
+            let graph = Paragraph::new(text)
+                .block(Block::default().title("").borders(Borders::ALL))
+                .style(Style::default().fg(Color::White).bg(Color::Black))
+                .scroll((0, 10000))
+                .wrap(Wrap { trim: true });
 
-            // draw a list
-            frame.render_widget(list, chunks[1]);
+            frame.render_widget(graph, chunks[1]);
         })?;
 
         // Iterate over all the keys that have been pressed since the
@@ -73,6 +91,8 @@ fn main() -> Result<()> {
                     terminal.clear()?;
                     return Ok(())
                 }
+                Key::Char('j') => {
+                }
                 // Otherwise, throw them away.
                 _ => (),
             }