WIP: apps/table: rewrite from msvc to tcc #596

Draft
Burer wants to merge 13 commits from apps/table-msvc-to-tcc into main
Owner
  • KOS API -> <sys/ksys.h> wrappers; box_lib -> <clayer/boxlib.h> with LIBS="-lbox_lib"; file I/O -> fn70 wrappers; strings/math/alloc -> libc.
  • Split the old plumbing out: kosSyst/mcsmemm/KosFile/math2/stdafx/use_library.h and all *.cpp removed; new func/parser/calc/table .c/.h.
  • Entry crtStartUp/kos_Main -> main(argc, argv); MSVC __asm and Windows type aliases dropped; clean C types (int/uint32_t) throughout.
  • Fix latent bugs surfaced by the switch to libc malloc/strcmp:
    • values[] relied on zeroed allocation;
    • make_cell_name malloc-size precedence and caption leak;
    • LoadCSV line leak;
    • calc_callback index-0 NULL access;
    • str[i-1] out-of-bounds guards;
    • parser null-guards (if/min/max/avg) and divide-by-zero (rand, '/'); logic_or 1.1 -> 1.0. arctg now real (atan).
- KOS API -> <sys/ksys.h> wrappers; box_lib -> <clayer/boxlib.h> with LIBS="-lbox_lib"; file I/O -> fn70 wrappers; strings/math/alloc -> libc. - Split the old plumbing out: kosSyst/mcsmemm/KosFile/math2/stdafx/use_library.h and all *.cpp removed; new func/parser/calc/table .c/.h. - Entry crtStartUp/kos_Main -> main(argc, argv); MSVC __asm and Windows type aliases dropped; clean C types (int/uint32_t) throughout. - Fix latent bugs surfaced by the switch to libc malloc/strcmp: - values[] relied on zeroed allocation; - make_cell_name malloc-size precedence and caption leak; - LoadCSV line leak; - calc_callback index-0 NULL access; - str[i-1] out-of-bounds guards; - parser null-guards (if/min/max/avg) and divide-by-zero (rand, '/'); logic_or 1.1 -> 1.0. arctg now real (atan).
Burer force-pushed apps/table-msvc-to-tcc from ce5e229780 to bb97c6c66d 2026-07-23 13:07:12 +00:00 Compare
Burer added 1 commit 2026-07-23 13:10:00 +00:00
apps/table: port from MSVC C++ to C for kos32-tcc
Test PR / Build (es_ES) (pull_request) Successful in 1m57s
Test PR / Build (ru_RU) (pull_request) Successful in 2m5s
Test PR / Build (en_US) (pull_request) Successful in 2m12s
e62e58f520
The Linux autobuild has no MSVC and builds with CONFIG_NO_MSVC=full, so
the table (spreadsheet) app was silently skipped. Rewrite it in clean C
against the KolibriOS TCC toolchain so it builds in CI again.

- KOS API -> <sys/ksys.h> wrappers; box_lib -> <clayer/boxlib.h> with
  LIBS="-lbox_lib"; file I/O -> fn70 wrappers; strings/math/alloc -> libc.
- Split the old plumbing out: kosSyst/mcsmemm/KosFile/math2/stdafx/
  use_library.h and all *.cpp removed; new func/parser/calc/table .c/.h.
- Entry crtStartUp/kos_Main -> main(argc, argv); MSVC __asm and Windows
  type aliases dropped; clean C types (int/uint32_t) throughout.
- Tupfile.lua now uses use_tcc.lua (link_tcc + box_lib), gated on
  NO_TCC/NO_FASM. data/Tupfile.lua: TABLE moved from the NO_MSVC block
  to the TCC(+FASM) block.
- Fix latent bugs surfaced by the switch to libc malloc/strcmp: values[]
  relied on zeroed allocation; make_cell_name malloc-size precedence and
  caption leak; LoadCSV line leak; calc_callback index-0 NULL access;
  str[i-1] out-of-bounds guards; parser null-guards (if/min/max/avg) and
  divide-by-zero (rand, '/'); logic_or 1.1 -> 1.0. arctg now real (atan).
Burer force-pushed apps/table-msvc-to-tcc from bb97c6c66d to e62e58f520 2026-07-23 13:10:00 +00:00 Compare
Burer added 1 commit 2026-07-23 13:29:07 +00:00
apps/table: fix viewport clamp, mouse coords, save, row-100 labels
Test PR / Build (es_ES) (pull_request) Successful in 1m58s
Test PR / Build (ru_RU) (pull_request) Successful in 2m6s
Test PR / Build (en_US) (pull_request) Successful in 2m11s
7b7a79184d
- Clamp the scroll viewport to the real table bounds so the last
  row/column is reachable and enlarging the window at the scroll end no
  longer reveals empty cells past the end (bugs 1, 2).
- Mouse: fn37.1 already returns work-area coordinates, so drop the extra
  -5 / -skin_height that shifted every click up and to the left (bug 3).
- Save: stop using _ksys_file_create() - it leaves the fn70 p20
  separator byte uninitialized, corrupting the request; create/truncate
  via fn70.2 with p20=0 (bug 4).
- Render 3-digit row captions and size the grid to columns A..CZ x
  rows 1..100 (A1..CZ100).
Burer added 1 commit 2026-07-23 13:48:32 +00:00
apps/table: fix scroll reaching the last cell and blank trailing strips
Test PR / Build (ru_RU) (pull_request) Successful in 1m59s
Test PR / Build (es_ES) (pull_request) Successful in 2m10s
Test PR / Build (en_US) (pull_request) Successful in 2m11s
05b057f9d8
- Scrollbar max_area was count-2, one short of the clamp limit, so the
  last column/row stayed clipped at max scroll. Use count-1 so the
  scrollbar can reach the clamped end (last cell fully visible).
- Paint the strip past the last visible column/row so no stale pixels
  ("holes") show when the table is narrower/shorter than the viewport or
  the last cell does not divide the area evenly.
Burer added 1 commit 2026-07-23 14:07:41 +00:00
apps/table: pixel-level scroll so the viewport sticks flush to the table
Test PR / Build (en_US) (pull_request) Successful in 2m21s
Test PR / Build (ru_RU) (pull_request) Successful in 2m27s
Test PR / Build (es_ES) (pull_request) Successful in 2m31s
dbbae23af5
Index-based scrolling could only align whole cells, leaving a gap or a
clipped last cell. Add a sub-cell pixel offset (off_x/off_y): clamp_view
now clamps the scroll in pixels and splits it into (first visible cell,
offset), so the last row/column ends exactly at the viewport edge.

draw_grid redrawn accordingly: cell bars are clipped to the data area and
the half-scrolled first row/column spills under the headers, which are
painted on top; grid lines drawn once per row/column. Drops the
now-unused DrawCell / clear_cell_slow / sel_moved fast-path.
Burer added 1 commit 2026-07-23 14:11:26 +00:00
apps/table: drop the full-viewport clear to avoid redraw flicker
Test PR / Build (es_ES) (pull_request) Successful in 2m42s
Test PR / Build (en_US) (pull_request) Successful in 2m59s
Test PR / Build (ru_RU) (pull_request) Successful in 3m8s
815235ee25
The cells already tile the whole data area (bars + grid lines cover it),
so clearing the entire grid to white every frame only caused a visible
flash on selection moves. Redraw cells in place instead and blank just
the strip past the last cell (needed only when the table is smaller than
the viewport). Typing in a cell still touches only the edit box.
Burer added 1 commit 2026-07-23 14:12:15 +00:00
apps/table: drop dead trailing-strip clear
Test PR / Build (en_US) (pull_request) Successful in 3m2s
Test PR / Build (es_ES) (pull_request) Successful in 3m6s
Test PR / Build (ru_RU) (pull_request) Successful in 1m59s
00a1ead9b4
The table is always larger than the viewport (min ~1590x1521 px vs a
smaller grid), so the cells always tile the whole data area and the
"table smaller than viewport" strip clear can never run. Remove it.
Burer added 1 commit 2026-07-23 14:30:22 +00:00
apps/table: make pixel scroll the primary state (fix clamp bounce)
Test PR / Build (es_ES) (pull_request) Successful in 1m55s
Test PR / Build (ru_RU) (pull_request) Successful in 2m6s
Test PR / Build (en_US) (pull_request) Successful in 2m11s
81ed5b56c6
Scrolling was stored as a whole-cell index and only converted to pixels
inside clamp_view, so the scrollbar/arrows set an index the clamp then
snapped back to the flush position - the thumb bounced and the last
row/column could not be reached exactly.

Store the scroll as pixels (scroll_x/scroll_y); clamp_view clamps that
and derives grid.firstx/firsty + off_x/off_y for drawing. The scrollbar,
wheel and ensure_visible (used by selection/edit) all work in pixels, so
selecting the last cell scrolls it flush and the scrollbar no longer
rebounds.
Burer added 1 commit 2026-07-23 14:41:11 +00:00
apps/table: reach the last row/column and keep header dividers
Test PR / Build (ru_RU) (pull_request) Successful in 2m0s
Test PR / Build (en_US) (pull_request) Successful in 2m5s
Test PR / Build (es_ES) (pull_request) Successful in 2m9s
6d06c2abb1
- Arrow keys used >= against the last index, blocking entry into the
  last column/row; use > so CZ / row 100 are reachable.
- Mouse cell hit-test scanned 0..count-1 (missing the last cell) and the
  click branch required mouse_x <= cell_x[nx-1] (the last column's left
  edge, excluding the column itself). Scan the visible range firstx..nx /
  firsty..ny and gate on the data area, so the last cell is clickable
  (also stops matching scrolled-off columns).
- The header/table divider lines were only the first cell's grid line, so
  they vanished once the first row/column scrolled under the header. Draw
  fixed dividers at x=cell_w[0] and y=cell_h[0] every frame.
Burer added 2 commits 2026-07-23 16:21:37 +00:00
sel_moved / sel_end_move / prev_x / prev_y / was_single_selection drove
the old partial-redraw fast path, which is gone - they were written all
over but never read. Remove them and their assignments, and fold the
now-trivial check_sel() into move_selection().
apps/table: order the file into clear sections
Test PR / Build (es_ES) (pull_request) Successful in 2m29s
Test PR / Build (en_US) (pull_request) Successful in 2m36s
Test PR / Build (ru_RU) (pull_request) Successful in 2m42s
98c8a791c3
The declarations were a mix of #defines, variables and structs
interleaved. Group them: constants first, then the cell model (shared
with calc.c), then UI state, then the box_lib widgets. Mark the
table-only globals static; keep the model globals extern-visible.
Burer added 1 commit 2026-07-23 16:35:22 +00:00
apps/table: wrap the cell model in a Table struct
Test PR / Build (ru_RU) (pull_request) Successful in 1m51s
Test PR / Build (en_US) (pull_request) Successful in 2m0s
Test PR / Build (es_ES) (pull_request) Successful in 2m3s
062896bac5
Group the scattered model globals (col_count/row_count/cell_w/cell_h/
cell_x/cell_y/cells/values) into a single `Table tbl`, declared in
calc.h and shared between table.c (UI) and calc.c (engine). Rename the
public model operations to table_* methods: init->table_init,
reinit->table_reset, calculate_values->table_recalc, SaveFile->table_save,
LoadFile->table_load, fill_cells->table_fill,
change_formula->table_shift_formula.
Burer added 1 commit 2026-07-23 16:43:27 +00:00
apps/table: dissolve the func.c grab-bag into the right modules
Test PR / Build (ru_RU) (pull_request) Successful in 1m53s
Test PR / Build (en_US) (pull_request) Successful in 1m58s
Test PR / Build (es_ES) (pull_request) Successful in 2m5s
1e540592d0
func.c mixed number-parsing helpers with KOS drawing helpers. Split them
by concern: convert() (+convert_error/ERROR) moves to the parser engine
(parser.c/.h, used by parser and calc); ftoa()/strnicmp() become static
in calc.c (their only user); the draw_* wrappers become static in
table.c (UI only). Drawing still needs raw syscalls (fn4 font flags, fn38
invert) that ksys.h does not wrap. Delete func.c/func.h and drop it from
the Tupfile. Also fix EventLoadFile, mangled by the LoadFile rename.
Burer added 1 commit 2026-07-23 16:48:07 +00:00
apps/table: draw via ksys.h wrappers instead of raw int 0x40
Test PR / Build (ru_RU) (pull_request) Successful in 1m49s
Test PR / Build (es_ES) (pull_request) Successful in 1m58s
Test PR / Build (en_US) (pull_request) Successful in 2m2s
9e6d43bc62
The fn4 font flag and the fn38 XOR-line flag are just values the kernel
reads from ecx/edx, which _ksys_draw_text/_ksys_draw_line already load
from their color argument. Pack the flag into that argument and call the
wrappers, dropping the hand-written syscalls. No inline asm remains in
the program.
Doczom added the AI label 2026-07-24 08:12:50 +00:00
Owner

Из-за переименования файлов невозможно оценить по diff файлу внесённые изменения

Из-за переименования файлов невозможно оценить по diff файлу внесённые изменения
Owner

Why all this effort to eliminate MSVC?

Why all this effort to eliminate MSVC?
Author
Owner

Why all this effort to eliminate MSVC?

  1. We weren't able to set up it in new autobuild, so now system just missing MSVC programs.
  2. Proprietary compiler with very old SDK for KOS.
  3. Rewritten programs are usually smaller in size.
> Why all this effort to eliminate MSVC? 1. We weren't able to set up it in new autobuild, so now system just missing MSVC programs. 2. Proprietary compiler with very old SDK for KOS. 3. Rewritten programs are usually smaller in size.
All checks were successful
Test PR / Build (ru_RU) (pull_request) Successful in 1m49s
Required
Details
Test PR / Build (es_ES) (pull_request) Successful in 1m58s
Required
Details
Test PR / Build (en_US) (pull_request) Successful in 2m2s
Required
Details
Checking for merge conflicts…
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin apps/table-msvc-to-tcc:apps/table-msvc-to-tcc
git checkout apps/table-msvc-to-tcc
Sign in to join this conversation.
No Reviewers
No labels AI
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KolibriOS/kolibrios#596