MCPcopy Create free account
hub / github.com/Eeive/Evcode-ide / draw

Function draw

src/ui/mod.rs:23–188  ·  view source on GitHub ↗
(f: &mut Frame, app: &mut App)

Source from the content-addressed store, hash-verified

21}
22
23pub fn draw(f: &mut Frame, app: &mut App) {
24 let area = f.area();
25 let colors = Colors::from_theme(&app.theme);
26
27 let terminal_height = if app.show_terminal { 12 } else { 0 };
28 let chunks = Layout::default()
29 .direction(Direction::Vertical)
30 .constraints([
31 Constraint::Length(1),
32 Constraint::Min(1),
33 Constraint::Length(terminal_height),
34 Constraint::Length(1),
35 ])
36 .split(area);
37
38 tabs::draw_tabs(f, chunks[0], app, &colors);
39
40 if let Some(file) = app.editor.files.get_mut(app.editor.current_file) {
41 let lang = file.lang;
42 let is_focused = app.focus == Focus::Editor;
43 let line_count = file.buffer.line_count();
44 let (cursor_row, cursor_col) = file.buffer.cursor();
45 let title = file.title();
46 let is_home = file.path.is_none();
47 let visible_height = chunks[1].height.saturating_sub(2) as usize;
48
49 if !is_home {
50 let max_scroll = line_count.saturating_sub(visible_height.max(1));
51 file.scroll_top = file.scroll_top.min(max_scroll);
52
53 if visible_height > 0 {
54 if cursor_row < file.scroll_top {
55 file.scroll_top = cursor_row;
56 } else if cursor_row >= file.scroll_top + visible_height {
57 file.scroll_top = cursor_row - visible_height + 1;
58 }
59 }
60 } else {
61 file.scroll_top = 0;
62 }
63
64 let scroll_row = file.scroll_top;
65
66 let highlighted: Text<'static> = {
67 let selection = file.buffer.selection_range().map(|(s, e)| {
68 if s < e { (s, e) } else { (e, s) }
69 });
70
71 let start = scroll_row;
72 let end = (start + visible_height).min(file.buffer.line_count());
73 let mut scratch = String::new();
74 let mut lines = Vec::with_capacity(end.saturating_sub(start));
75 for r in start..end {
76 file.buffer.line_text_into(r, &mut scratch);
77 let base_line = highlight_line(&scratch, lang);
78 let mut spans = Vec::with_capacity(base_line.spans.len());
79
80 let mut current_col = 0;

Callers 1

runMethod · 0.85

Calls 15

draw_tabsFunction · 0.85
highlight_lineFunction · 0.85
push_styled_runsFunction · 0.85
line_num_widthFunction · 0.85
draw_terminalFunction · 0.85
draw_diff_viewFunction · 0.85
draw_status_barFunction · 0.85
draw_file_treeFunction · 0.85
draw_teleportFunction · 0.85
draw_naming_popupFunction · 0.85
draw_confirm_deleteFunction · 0.85
cursorMethod · 0.80

Tested by

no test coverage detected