this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

better drawing

alice d4c23fa5 e3558144

+29 -52
+12 -9
tic80_rust/src/editor/code.rs
··· 259 259 260 260 #[allow(clippy::cast_possible_truncation, clippy::too_many_lines)] 261 261 pub fn draw(&mut self, fb: &mut crate::gfx::framebuffer::Framebuffer, area: Area) { 262 - let gutter_w = 24i32; 262 + // Gutter width: 3 digits * 6px = 18px, plus a 1px gap before code 263 + let gutter_w = 18i32; 264 + let gap = 1i32; 263 265 // Match TIC-80 editor line pitch: 7px (TIC_FONT_HEIGHT + 1) 264 266 let line_pitch = 7i32; 265 267 let lines_vis = (area.h / line_pitch).max(1) as usize; 266 - let cols_vis = ((area.w - gutter_w) / 6).max(1) as usize; 268 + let cols_vis = ((area.w - gutter_w - gap) / 6).max(1) as usize; 267 269 self.ensure_visible(lines_vis, cols_vis); 268 270 269 271 // Clip to drawing area ··· 279 281 let gutter_y = area.y + i32::try_from(i).unwrap_or(0) * line_pitch; 280 282 let ln = line_idx + 1; 281 283 let label = format!("{ln:>3}"); 282 - let _ = fb.print_text(&label, area.x + 2, gutter_y, 6, true, 1, false); 284 + // Right-justified 3-digit label, drawn flush to gutter (no extra left/right padding) 285 + let _ = fb.print_text(&label, area.x, gutter_y, 14, true, 1, true); 283 286 284 287 // Text slice 285 288 let mut line = self.rope.line(line_idx).to_string(); ··· 293 296 let line_char_start = self.rope.line_to_char(line_idx); 294 297 let sel = self.selection_range_idx(); 295 298 for (i_vis, ch) in vis.chars().enumerate() { 296 - let cell_x = area.x + gutter_w + i32::try_from(i_vis).unwrap_or(0) * 6; 299 + let cell_x = area.x + gutter_w + gap + i32::try_from(i_vis).unwrap_or(0) * 6; 297 300 let cell_y = gutter_y; 298 301 let global_idx = line_char_start + start + i_vis; 299 302 let selected = sel.is_some_and(|(s, e)| global_idx >= s && global_idx < e); ··· 304 307 fb.rect(cell_x - 1, cell_y - 1, 7, 7, 14); 305 308 // Dark glyph on top 306 309 let s = ch.to_string(); 307 - let _ = fb.print_text(&s, cell_x, cell_y, 15, true, 1, false); 310 + let _ = fb.print_text(&s, cell_x, cell_y, 15, true, 1, true); 308 311 } else { 309 312 // Normal glyph (no selection overlay) 310 313 let s = ch.to_string(); 311 - // TIC default text color (no syntax) is white (12) 312 - let _ = fb.print_text(&s, cell_x, cell_y, 12, true, 1, false); 314 + // TIC default text color (no syntax) is white (12), 6px tall 315 + let _ = fb.print_text(&s, cell_x, cell_y, 12, true, 1, true); 313 316 } 314 317 } 315 318 } ··· 318 321 if self.caret_line >= self.scroll_line && self.caret_line < self.scroll_line + lines_vis { 319 322 let row = i32::try_from(self.caret_line - self.scroll_line).unwrap_or(0); 320 323 let col = i32::try_from(self.caret_col.saturating_sub(self.scroll_col)).unwrap_or(0); 321 - let cell_x = area.x + gutter_w + col * 6; 324 + let cell_x = area.x + gutter_w + gap + col * 6; 322 325 let cell_y = area.y + row * line_pitch; 323 326 // TIC-80 caret style: drop shadow rect (black) then caret rect (cursor color, default 2), both 7x7, offset by 1px 324 327 fb.rect(cell_x, cell_y, 7, 7, 0); ··· 338 341 let ch = full.chars().nth(idx).unwrap_or(' '); 339 342 let s = ch.to_string(); 340 343 // Render underlying glyph in background color to simulate inversion 341 - let _ = fb.print_text(&s, cell_x, cell_y, 15, true, 1, false); 344 + let _ = fb.print_text(&s, cell_x, cell_y, 15, true, 1, true); 342 345 } 343 346 } 344 347 }
+2 -9
tic80_rust/src/editor/ui.rs
··· 133 133 // TIC-80 draws toolbar in white 134 134 fb.rect(0, 0, 240, bar_h, 12); 135 135 136 - // Tabs (underline only for CODE) 137 - let (code_col, _cons_col) = match self.active { 138 - // Use grey underline similar to CODE EDITOR text 139 - Tab::Code | Tab::Console => (14, 14), 140 - }; 141 - // Minimal underline only for CODE 142 - fb.rect(self.tab_code.x, bar_h - 1, self.tab_code.w, 1, code_col); 136 + // No tab underline for now; only the CODE label at top-left. 143 137 // Buttons 144 138 // Buttons: skip heavy boxes in code prototype 145 139 146 140 // Labels (using small scale) 147 - // Left title label: drop shadow 1px (dark grey 15) then grey (14), like "CODE EDITOR" 141 + // Left title label: grey text only (no shadow for now) 148 142 let title_x = 4; 149 143 let title_y = 1; // 1px top margin 150 - let _ = fb.print_text("CODE", title_x + 1, title_y + 1, 15, true, 1, true); 151 144 let _ = fb.print_text("CODE", title_x, title_y, 14, true, 1, true); 152 145 // Center button labels (placeholder, keep white for readability) 153 146 let adv = 6i32;
+2 -7
tic80_rust/src/main.rs
··· 611 611 ui.draw(&mut fbb); 612 612 if ui.active == tic80_rust::editor::ui::Tab::Code { 613 613 if let Some(cb) = code_buf.as_mut() { 614 - let area = CodeArea { x: 0, y: 12, w: 240, h: 124 }; 614 + let area = CodeArea { x: 0, y: 7, w: 240, h: 129 }; 615 615 cb.draw(&mut fbb, area); 616 616 } 617 617 } ··· 713 713 { 714 714 let mut fbb = fb.borrow_mut(); 715 715 ui.draw(&mut fbb); 716 - let area = CodeArea { 717 - x: 0, 718 - y: 12, 719 - w: 240, 720 - h: 124, 721 - }; 716 + let area = CodeArea { x: 0, y: 7, w: 240, h: 129 }; 722 717 code.draw(&mut fbb, area); 723 718 } 724 719 } else {
+7 -12
tic80_rust/tests/editor_code_view_tests.rs
··· 10 10 let mut cb = CodeBuffer::from_text(text); 11 11 let fb = Rc::new(RefCell::new(Framebuffer::new())); 12 12 let mut fbb = fb.borrow_mut(); 13 - let area = Area { 14 - x: 0, 15 - y: 12, 16 - w: 240, 17 - h: 40, 18 - }; 13 + let area = Area { x: 0, y: 7, w: 240, h: 40 }; 19 14 cb.draw(&mut fbb, area); 20 - // Expect some non-zero pixels in gutter (left side) 15 + // Expect some non-zero pixels in gutter (left side, 0..18) 21 16 let mut gutter_ink = 0; 22 - for y in 12..20 { 23 - for x in 2..22 { 17 + for y in 7..14 { 18 + for x in 0..18 { 24 19 if fbb.pix(x, y, None).unwrap_or(0) != 0 { 25 20 gutter_ink += 1; 26 21 } 27 22 } 28 23 } 29 24 assert!(gutter_ink > 0); 30 - // Expect some text pixels in the first line area after gutter (x >= 24) 25 + // Expect some text pixels in the first line area after gutter+gap (x >= 19) 31 26 let mut line_ink = 0; 32 - for x in 24..60 { 33 - if fbb.pix(x, 12, None).unwrap_or(0) != 0 { 27 + for x in 19..60 { 28 + if fbb.pix(x, 7, None).unwrap_or(0) != 0 { 34 29 line_ink += 1; 35 30 } 36 31 }
+6 -15
tic80_rust/tests/editor_selection_shadow_tests.rs
··· 24 24 25 25 let fb_rc = Rc::new(RefCell::new(Framebuffer::new())); 26 26 let mut fb = fb_rc.borrow_mut(); 27 - let area = Area { 28 - x: 0, 29 - y: 12, 30 - w: 240, 31 - h: 40, 32 - }; 27 + let area = Area { x: 0, y: 7, w: 240, h: 40 }; 33 28 cb.draw(&mut fb, area); 34 29 35 30 // Pick column 1 (the 'b') well inside selection run 36 - let gutter_w = 24i32; 31 + let gutter_w = 18i32; // plus 1px gap in renderer 37 32 let col_x = gutter_w + 6 + 2; // inside col #1 38 33 39 34 // With TIC-80 logic there should be NO black seam between consecutive lines. ··· 60 55 61 56 let fb_rc = Rc::new(RefCell::new(Framebuffer::new())); 62 57 let mut fb = fb_rc.borrow_mut(); 63 - let area = Area { 64 - x: 0, 65 - y: 12, 66 - w: 240, 67 - h: 20, 68 - }; 58 + let area = Area { x: 0, y: 7, w: 240, h: 20 }; 69 59 cb.draw(&mut fb, area); 70 60 71 - let gutter_w = 24i32; 72 - let right_edge_x = gutter_w + 3 * 6 - 1; // vertical shadow at right edge of col2 61 + let gutter_w = 18i32; // plus 1px gap 62 + let gap = 1i32; 63 + let right_edge_x = gutter_w + gap + 3 * 6 - 1; // vertical shadow at right edge of col2 73 64 let base_y = area.y - 1; // selection fill starts at y-1; shadow spans 7 px down from y 74 65 75 66 let mut black_count = 0;