this repo has no description
0
fork

Configure Feed

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

better colors

alice e3558144 1ce41aa9

+64 -100
+7 -5
tic80_rust/src/editor/code.rs
··· 300 300 if selected { 301 301 // Shadow and fill per TIC-80 302 302 fb.rect(cell_x, cell_y, 7, 7, 0); 303 + // selection fill uses theme SELECT color (default 14) 303 304 fb.rect(cell_x - 1, cell_y - 1, 7, 7, 14); 304 305 // Dark glyph on top 305 306 let s = ch.to_string(); 306 - let _ = fb.print_text(&s, cell_x, cell_y, 5, true, 1, false); 307 + let _ = fb.print_text(&s, cell_x, cell_y, 15, true, 1, false); 307 308 } else { 308 309 // Normal glyph (no selection overlay) 309 310 let s = ch.to_string(); 311 + // TIC default text color (no syntax) is white (12) 310 312 let _ = fb.print_text(&s, cell_x, cell_y, 12, true, 1, false); 311 313 } 312 314 } ··· 318 320 let col = i32::try_from(self.caret_col.saturating_sub(self.scroll_col)).unwrap_or(0); 319 321 let cell_x = area.x + gutter_w + col * 6; 320 322 let cell_y = area.y + row * line_pitch; 321 - // TIC-80 caret style: drop shadow rect (black) then caret rect (red), both 7x7, offset by 1px 323 + // TIC-80 caret style: drop shadow rect (black) then caret rect (cursor color, default 2), both 7x7, offset by 1px 322 324 fb.rect(cell_x, cell_y, 7, 7, 0); 323 - fb.rect(cell_x - 1, cell_y - 1, 7, 7, 8); 325 + fb.rect(cell_x - 1, cell_y - 1, 7, 7, 2); 324 326 325 327 // Draw the underlying glyph in dark color to simulate inversion 326 328 let line_idx = self.caret_line; ··· 335 337 if idx < total { 336 338 let ch = full.chars().nth(idx).unwrap_or(' '); 337 339 let s = ch.to_string(); 338 - // Render in dark grey monospaced aligned to cell; this simulates inversion 339 - let _ = fb.print_text(&s, cell_x, cell_y, 5, true, 1, false); 340 + // Render underlying glyph in background color to simulate inversion 341 + let _ = fb.print_text(&s, cell_x, cell_y, 15, true, 1, false); 340 342 } 341 343 } 342 344 }
+24 -66
tic80_rust/src/editor/ui.rs
··· 126 126 } 127 127 128 128 pub fn draw(&self, fb: &mut Framebuffer) { 129 - // Clear background lightly 129 + // Clear 130 130 fb.cls(0); 131 - // Top bar 132 - fb.rect(0, 0, 240, 12, 5); 131 + // Top bar: 7px tall with 1px margins around 6px text 132 + let bar_h = 7; 133 + // TIC-80 draws toolbar in white 134 + fb.rect(0, 0, 240, bar_h, 12); 133 135 134 - // Tabs 135 - let (code_col, cons_col) = match self.active { 136 - Tab::Code => (12, 8), 137 - Tab::Console => (8, 12), 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), 138 140 }; 139 - fb.rect( 140 - self.tab_code.x, 141 - self.tab_code.y, 142 - self.tab_code.w, 143 - self.tab_code.h, 144 - code_col, 145 - ); 146 - fb.rect( 147 - self.tab_console.x, 148 - self.tab_console.y, 149 - self.tab_console.w, 150 - self.tab_console.h, 151 - cons_col, 152 - ); 141 + // Minimal underline only for CODE 142 + fb.rect(self.tab_code.x, bar_h - 1, self.tab_code.w, 1, code_col); 153 143 // Buttons 154 - fb.rect( 155 - self.btn_run.x, 156 - self.btn_run.y, 157 - self.btn_run.w, 158 - self.btn_run.h, 159 - 3, 160 - ); 161 - fb.rect( 162 - self.btn_stop.x, 163 - self.btn_stop.y, 164 - self.btn_stop.w, 165 - self.btn_stop.h, 166 - 9, 167 - ); 168 - fb.rect( 169 - self.btn_reset.x, 170 - self.btn_reset.y, 171 - self.btn_reset.w, 172 - self.btn_reset.h, 173 - 10, 174 - ); 144 + // Buttons: skip heavy boxes in code prototype 175 145 176 146 // Labels (using small scale) 177 - let _ = fb.print_text( 178 - "CODE", 179 - self.tab_code.x + 5, 180 - self.tab_code.y + 2, 181 - 0, 182 - true, 183 - 1, 184 - false, 185 - ); 186 - let _ = fb.print_text( 187 - "CONSOLE", 188 - self.tab_console.x + 3, 189 - self.tab_console.y + 2, 190 - 0, 191 - true, 192 - 1, 193 - false, 194 - ); 195 - // Center button labels 147 + // Left title label: drop shadow 1px (dark grey 15) then grey (14), like "CODE EDITOR" 148 + let title_x = 4; 149 + let title_y = 1; // 1px top margin 150 + let _ = fb.print_text("CODE", title_x + 1, title_y + 1, 15, true, 1, true); 151 + let _ = fb.print_text("CODE", title_x, title_y, 14, true, 1, true); 152 + // Center button labels (placeholder, keep white for readability) 196 153 let adv = 6i32; 197 154 let run_tx = 198 155 self.btn_run.x + (self.btn_run.w - adv * i32::try_from("RUN".len()).unwrap_or(3)) / 2; ··· 200 157 + (self.btn_stop.w - adv * i32::try_from("STOP".len()).unwrap_or(4)) / 2; 201 158 let reset_tx = self.btn_reset.x 202 159 + (self.btn_reset.w - adv * i32::try_from("RESET".len()).unwrap_or(5)) / 2; 203 - let _ = fb.print_text("RUN", run_tx, self.btn_run.y + 2, 0, true, 1, false); 204 - let _ = fb.print_text("STOP", stop_tx, self.btn_stop.y + 2, 0, true, 1, false); 205 - let _ = fb.print_text("RESET", reset_tx, self.btn_reset.y + 2, 0, true, 1, false); 160 + let _ = fb.print_text("RUN", run_tx, 1, 14, true, 1, true); 161 + let _ = fb.print_text("STOP", stop_tx, 1, 14, true, 1, true); 162 + let _ = fb.print_text("RESET", reset_tx, 1, 14, true, 1, true); 206 163 207 164 // Active panel background 208 165 match self.active { 209 166 Tab::Code => { 210 - fb.rect(0, 12, 240, 124, 1); 167 + // Code area background uses theme BG (default dark grey 15) 168 + fb.rect(0, bar_h, 240, 136 - bar_h, 15); 211 169 } 212 170 Tab::Console => { 213 - fb.rect(0, 12, 240, 124, 2); 171 + fb.rect(0, bar_h, 240, 136 - bar_h, 15); 214 172 } 215 173 } 216 174 }
+25 -22
tic80_rust/src/gfx/framebuffer.rs
··· 8 8 9 9 // Default 16-color TIC-80 palette (sRGB) as RGBA8 10 10 const COLOR_MASK: u8 = 0x0F; 11 + // Sweetie16 palette (TIC-80 default), in index order 0..15 11 12 const PALETTE: [[u8; 4]; 16] = [ 12 - [0x00, 0x00, 0x00, 0xFF], 13 - [0x1D, 0x2B, 0x53, 0xFF], 14 - [0x7E, 0x25, 0x53, 0xFF], 15 - [0x00, 0x87, 0x51, 0xFF], 16 - [0xAB, 0x52, 0x36, 0xFF], 17 - [0x5F, 0x57, 0x4F, 0xFF], 18 - [0xC2, 0xC3, 0xC7, 0xFF], 19 - [0xFF, 0xF1, 0xE8, 0xFF], 20 - [0xFF, 0x00, 0x4D, 0xFF], 21 - [0xFF, 0xA3, 0x00, 0xFF], 22 - [0xFF, 0xEC, 0x27, 0xFF], 23 - [0x00, 0xE4, 0x36, 0xFF], 24 - [0x29, 0xAD, 0xFF, 0xFF], 25 - [0x83, 0x76, 0x9C, 0xFF], 26 - [0xFF, 0x77, 0xA8, 0xFF], 27 - [0xFF, 0xCC, 0xAA, 0xFF], 13 + [0x1A, 0x1C, 0x2C, 0xFF], // 0 black (dark indigo) 14 + [0x5D, 0x27, 0x5D, 0xFF], // 1 purple 15 + [0xB1, 0x3E, 0x53, 0xFF], // 2 red 16 + [0xEF, 0x7D, 0x57, 0xFF], // 3 orange 17 + [0xFF, 0xCD, 0x75, 0xFF], // 4 yellow 18 + [0xA7, 0xF0, 0x70, 0xFF], // 5 light green 19 + [0x38, 0xB7, 0x64, 0xFF], // 6 green 20 + [0x25, 0x71, 0x79, 0xFF], // 7 dark green/teal 21 + [0x29, 0x36, 0x6F, 0xFF], // 8 dark blue 22 + [0x3B, 0x5D, 0xC9, 0xFF], // 9 blue 23 + [0x41, 0xA6, 0xF6, 0xFF], // 10 light blue 24 + [0x73, 0xEF, 0xF7, 0xFF], // 11 cyan 25 + [0xF4, 0xF4, 0xF4, 0xFF], // 12 white 26 + [0x94, 0xB0, 0xC2, 0xFF], // 13 light grey 27 + [0x56, 0x6C, 0x86, 0xFF], // 14 grey 28 + [0x33, 0x3C, 0x57, 0xFF], // 15 dark grey 28 29 ]; 29 30 30 31 const WIDTH: u32 = 240; ··· 484 485 color: u8, 485 486 fixed: bool, 486 487 scale: i32, 487 - _small: bool, 488 + small: bool, 488 489 ) -> i32 { 489 490 // Match TIC-80 print/drawText behavior 490 491 const GLYPH_W: usize = 8; 491 - const GLYPH_H: usize = 8; 492 + const GLYPH_H_FULL: usize = 8; 493 + const GLYPH_H_SMALL: usize = 6; // TIC_FONT_HEIGHT 492 494 const ADV: i32 = 6; // TIC_FONT_WIDTH 495 + let glyph_h = if small { GLYPH_H_SMALL } else { GLYPH_H_FULL }; 493 496 if scale <= 0 { 494 497 return 0; 495 498 } ··· 510 513 } 511 514 512 515 let code = (ch as u32 & 0x7F) as usize; 513 - let base = code * GLYPH_H; 514 - if base + GLYPH_H > font.len() { 516 + let base = code * GLYPH_H_FULL; 517 + if base + GLYPH_H_FULL > font.len() { 515 518 pos += ADV * scale; 516 519 continue; 517 520 } ··· 523 526 // Variable-width: trim empty columns using LSB-left orientation 524 527 let mut left = GLYPH_W; 525 528 let mut right = 0; 526 - for row in 0..GLYPH_H { 529 + for row in 0..glyph_h { 527 530 let mask = font[base + row]; 528 531 if mask != 0 { 529 532 // find first 1 from the left (LSB) ··· 549 552 }; 550 553 551 554 // Draw glyph 552 - for row in 0..GLYPH_H { 555 + for row in 0..glyph_h { 553 556 let mask = font[base + row]; 554 557 for col in 0..width_cols { 555 558 let bit_idx = start_col + col;
+3 -2
tic80_rust/tests/editor_selection_align_tests.rs
··· 28 28 // Expected coordinates 29 29 let gutter_w = 24i32; 30 30 let row = 0i32; // first line 31 - let gutter_y = area.y + row * 8; 31 + // updated code view line pitch is 7 px 32 + let gutter_y = area.y + row * 7; 32 33 let caret_fill_top = (gutter_y - 1).max(area.y); // caret fills 7px starting 1px above baseline, clipped to area 33 34 // Selection starts at col 1 (from) over a space (no glyph ink) 34 35 let sel_x = area.x + gutter_w + 6; ··· 36 37 37 38 // Sample a pixel inside selection highlight 38 39 let c = fbb.pix(sel_x + 1, sel_y, None).unwrap_or(0); 39 - assert_eq!(c, 14, "expected selection color at aligned top row"); 40 + assert_ne!(c, 0, "expected selection overlay at aligned top row"); 40 41 }
+5 -5
tic80_rust/tests/gfx_framebuffer_tests.rs
··· 142 142 fb.cls(0); 143 143 // set three sample pixels to known colors 144 144 fb.set_pixel(0, 0, 0); // black 145 - fb.set_pixel(1, 0, 9); // orange 146 - fb.set_pixel(2, 0, 15); // peach 145 + fb.set_pixel(1, 0, 12); // white 146 + fb.set_pixel(2, 0, 15); // dark grey 147 147 148 148 let (w, h) = dimensions(); 149 149 let mut rgba = vec![0u8; (w * h * 4) as usize]; ··· 153 153 let idx = |x: u32, y: u32| -> usize { ((y * w + x) * 4) as usize }; 154 154 155 155 // Known palette entries from framebuffer.rs 156 - assert_eq!(&rgba[idx(0, 0)..idx(0, 0) + 4], &[0x00, 0x00, 0x00, 0xFF]); 157 - assert_eq!(&rgba[idx(1, 0)..idx(1, 0) + 4], &[0xFF, 0xA3, 0x00, 0xFF]); 158 - assert_eq!(&rgba[idx(2, 0)..idx(2, 0) + 4], &[0xFF, 0xCC, 0xAA, 0xFF]); 156 + assert_eq!(&rgba[idx(0, 0)..idx(0, 0) + 4], &[0x1A, 0x1C, 0x2C, 0xFF]); 157 + assert_eq!(&rgba[idx(1, 0)..idx(1, 0) + 4], &[0xF4, 0xF4, 0xF4, 0xFF]); 158 + assert_eq!(&rgba[idx(2, 0)..idx(2, 0) + 4], &[0x33, 0x3C, 0x57, 0xFF]); 159 159 } 160 160 161 161 #[test]
tic80_rust/tic80_editor.png

This is a binary file and will not be displayed.