fixes
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
2740db732b06065bfa286948a642cadc74a0ba16- Parents
-
4f77477 - Tree
319950d
2740db7
2740db732b06065bfa286948a642cadc74a0ba164f77477
319950d| Status | File | + | - |
|---|---|---|---|
| M |
CMakeLists.txt
|
6 | 1 |
| M |
c_src/pty_helpers.c
|
7 | 0 |
| M |
src/fortty.f90
|
20 | 15 |
| M |
src/text/atlas.f90
|
7 | 0 |
| M |
src/text/renderer.f90
|
7 | 6 |
CMakeLists.txtmodified@@ -30,7 +30,12 @@ add_library(helpers STATIC | ||
| 30 | 30 | ) |
| 31 | 31 | target_include_directories(helpers PUBLIC ${CMAKE_SOURCE_DIR}/include) |
| 32 | 32 | target_include_directories(helpers PRIVATE ${FREETYPE_INCLUDE_DIRS}) |
| 33 | -target_link_libraries(helpers PRIVATE glfw ${FREETYPE_LIBRARIES} util) | |
| 33 | +target_link_libraries(helpers PRIVATE glfw ${FREETYPE_LIBRARIES}) | |
| 34 | + | |
| 35 | +# Link util library for PTY on Linux (not needed on macOS) | |
| 36 | +if(UNIX AND NOT APPLE) | |
| 37 | + target_link_libraries(helpers PRIVATE util) | |
| 38 | +endif() | |
| 34 | 39 | |
| 35 | 40 | # Link fontconfig if available |
| 36 | 41 | if(FONTCONFIG_FOUND) |
c_src/pty_helpers.cmodified@@ -4,7 +4,14 @@ | ||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | #define _XOPEN_SOURCE 600 |
| 7 | + | |
| 8 | +/* Platform-specific PTY header */ | |
| 9 | +#if defined(__APPLE__) | |
| 10 | +#include <util.h> | |
| 11 | +#else | |
| 7 | 12 | #include <pty.h> |
| 13 | +#endif | |
| 14 | + | |
| 8 | 15 | #include <unistd.h> |
| 9 | 16 | #include <fcntl.h> |
| 10 | 17 | #include <sys/ioctl.h> |
src/fortty.f90modified@@ -263,7 +263,9 @@ program fortty | ||
| 263 | 263 | end if |
| 264 | 264 | |
| 265 | 265 | do row = 1, scr%rows |
| 266 | - y = real(row) * cell_height | |
| 266 | + ! Cell top-left y coordinate (for rectangles like selection/cursor) | |
| 267 | + ! Row 1 starts at y=0, row 2 at y=cell_height, etc. | |
| 268 | + y = real(row - 1) * cell_height | |
| 267 | 269 | |
| 268 | 270 | ! Determine if this row shows scrollback or screen content |
| 269 | 271 | sb_offset = scroll_offset - row + 1 |
@@ -279,17 +281,19 @@ program fortty | ||
| 279 | 281 | |
| 280 | 282 | x = real(col - 1) * cell_width |
| 281 | 283 | |
| 282 | - ! Draw selection background if selected | |
| 283 | - if (selection_contains(sel, row, col)) then | |
| 284 | - call renderer_draw_rect(ren, x, y, real(cell_width), real(cell_height), & | |
| 285 | - 0.3, 0.3, 0.6, 1.0) | |
| 286 | - end if | |
| 287 | - | |
| 284 | + ! Only render cells with actual text content | |
| 288 | 285 | if (cell%codepoint /= 32 .and. cell%codepoint /= 0) then |
| 286 | + ! Draw selection background if selected (only for text cells) | |
| 287 | + if (selection_contains(sel, row, col)) then | |
| 288 | + call renderer_draw_rect(ren, x, y, real(cell_width), real(cell_height), & | |
| 289 | + 0.3, 0.3, 0.6, 1.0) | |
| 290 | + end if | |
| 291 | + | |
| 289 | 292 | r = real(cell%fg%r) / 255.0 |
| 290 | 293 | g = real(cell%fg%g) / 255.0 |
| 291 | 294 | b = real(cell%fg%b) / 255.0 |
| 292 | - call renderer_draw_char(ren, x, y, cell%codepoint, r, g, b, 1.0) | |
| 295 | + ! Text baseline is at cell bottom; add cell_height to position correctly | |
| 296 | + call renderer_draw_char(ren, x, y + real(cell_height), cell%codepoint, r, g, b, 1.0) | |
| 293 | 297 | end if |
| 294 | 298 | end do |
| 295 | 299 | else |
@@ -304,17 +308,18 @@ program fortty | ||
| 304 | 308 | |
| 305 | 309 | x = real(col - 1) * cell_width |
| 306 | 310 | |
| 307 | - ! Draw selection background if selected | |
| 308 | - if (selection_contains(sel, row, col)) then | |
| 309 | - call renderer_draw_rect(ren, x, y, real(cell_width), real(cell_height), & | |
| 310 | - 0.3, 0.3, 0.6, 1.0) | |
| 311 | - end if | |
| 312 | - | |
| 311 | + ! Only render cells with actual text content | |
| 313 | 312 | if (cell%codepoint /= 32 .and. cell%codepoint /= 0) then |
| 313 | + ! Draw selection background if selected (only for text cells) | |
| 314 | + if (selection_contains(sel, row, col)) then | |
| 315 | + call renderer_draw_rect(ren, x, y, real(cell_width), real(cell_height), & | |
| 316 | + 0.3, 0.3, 0.6, 1.0) | |
| 317 | + end if | |
| 314 | 318 | r = real(cell%fg%r) / 255.0 |
| 315 | 319 | g = real(cell%fg%g) / 255.0 |
| 316 | 320 | b = real(cell%fg%b) / 255.0 |
| 317 | - call renderer_draw_char(ren, x, y, cell%codepoint, r, g, b, 1.0) | |
| 321 | + ! Text baseline is at cell bottom; add cell_height to position correctly | |
| 322 | + call renderer_draw_char(ren, x, y + real(cell_height), cell%codepoint, r, g, b, 1.0) | |
| 318 | 323 | end if |
| 319 | 324 | end do |
| 320 | 325 | end if |
src/text/atlas.f90modified@@ -44,6 +44,7 @@ contains | ||
| 44 | 44 | integer :: cp, i |
| 45 | 45 | type(glyph_t) :: g |
| 46 | 46 | type(c_ptr) :: bitmap_ptr |
| 47 | + integer(c_int8_t), target :: white_pixel(1) | |
| 47 | 48 | |
| 48 | 49 | if (.not. font%loaded) then |
| 49 | 50 | print *, "Error: Cannot create atlas from unloaded font" |
@@ -72,6 +73,12 @@ contains | ||
| 72 | 73 | atlas%width, atlas%height, 0, & |
| 73 | 74 | GL_RED, GL_UNSIGNED_BYTE, c_null_ptr) |
| 74 | 75 | |
| 76 | + ! Add a solid white pixel at position (0,0) for solid rectangle rendering | |
| 77 | + ! This allows renderer_draw_rect to sample a non-transparent pixel | |
| 78 | + white_pixel(1) = -1_c_int8_t ! 255 as signed byte | |
| 79 | + call glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, & | |
| 80 | + GL_RED, GL_UNSIGNED_BYTE, c_loc(white_pixel)) | |
| 81 | + | |
| 75 | 82 | ! Initialize glyph array |
| 76 | 83 | do cp = 0, 127 |
| 77 | 84 | call glyph_init(atlas%glyphs(cp)) |
src/text/renderer.f90modified@@ -358,12 +358,13 @@ contains | ||
| 358 | 358 | x1 = x0 + real(w, c_float) |
| 359 | 359 | y1 = y0 + real(h, c_float) |
| 360 | 360 | |
| 361 | - ! Use UV coords (0,0) which should sample a solid pixel from atlas | |
| 362 | - ! Most atlases have a solid white pixel at origin | |
| 363 | - u0 = 0.0_c_float | |
| 364 | - v0 = 0.0_c_float | |
| 365 | - u1 = 0.001_c_float ! Tiny region to avoid sampling other glyphs | |
| 366 | - v1 = 0.001_c_float | |
| 361 | + ! Sample from center of white pixel at atlas origin (0.5, 0.5) in pixel coords | |
| 362 | + ! Atlas is 1024x1024, so UV center = 0.5/1024 ≈ 0.000488 | |
| 363 | + ! Use same UV for all vertices to get solid color (no interpolation) | |
| 364 | + u0 = 0.0005_c_float | |
| 365 | + v0 = 0.0005_c_float | |
| 366 | + u1 = 0.0005_c_float | |
| 367 | + v1 = 0.0005_c_float | |
| 367 | 368 | |
| 368 | 369 | ! Build 6 vertices for 2 triangles |
| 369 | 370 | base = r%vertex_count * FLOATS_PER_VERTEX + 1 |