From ce5508f8e4459797d9778d9d15da4b6a0061ce3b Mon Sep 17 00:00:00 2001 From: Kittycannon Date: Sun, 7 Jun 2026 12:50:59 -0600 Subject: [PATCH] changed test for windows, to be removed --- makefile | 3 ++- src/desktoplib/main.cpp | 5 +++++ src/desktoplib/terminal/ui/InnerScroll.cpp | 4 ++-- src/desktoplib/terminal/ui/MenuMap.cpp | 6 +++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/makefile b/makefile index 590408f..86e3135 100644 --- a/makefile +++ b/makefile @@ -14,7 +14,8 @@ OBJEXT := o #Flags, Libraries and Includes ROOT := ./ -CFLAGS := -std=c++20 -O2 \ +CDEFS := -DDESKTOPLIB_TEST +CFLAGS := -std=c++20 -O2 $(CDEFS) \ -Wall -Werror -Wextra \ -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align \ -Wunused -Woverloaded-virtual -Wconversion \ diff --git a/src/desktoplib/main.cpp b/src/desktoplib/main.cpp index eaf3505..85940c3 100644 --- a/src/desktoplib/main.cpp +++ b/src/desktoplib/main.cpp @@ -7,7 +7,12 @@ #include #include +#include + int main() { + SetConsoleOutputCP(CP_UTF8); + SetConsoleCP(CP_UTF8); + using namespace ckitty::terminal; Terminal term; diff --git a/src/desktoplib/terminal/ui/InnerScroll.cpp b/src/desktoplib/terminal/ui/InnerScroll.cpp index 00594d7..8c15b8b 100644 --- a/src/desktoplib/terminal/ui/InnerScroll.cpp +++ b/src/desktoplib/terminal/ui/InnerScroll.cpp @@ -46,8 +46,8 @@ namespace ckitty::terminal { int thumbH = std::max(1, (viewH * viewH) / totalH); // Calculate thumb position - float scrollPercent = float(scrollY) / (totalH - viewH); - int thumbPos = int(scrollPercent * (viewH - thumbH)); + float scrollPercent = float(scrollY) / float(totalH - viewH); + int thumbPos = int(scrollPercent * float(viewH - thumbH)); t << thumbColor; for (int y = 0; y < thumbH; ++y) { diff --git a/src/desktoplib/terminal/ui/MenuMap.cpp b/src/desktoplib/terminal/ui/MenuMap.cpp index a419bb9..9dddb41 100644 --- a/src/desktoplib/terminal/ui/MenuMap.cpp +++ b/src/desktoplib/terminal/ui/MenuMap.cpp @@ -5,12 +5,12 @@ namespace ckitty::terminal { MenuMap::MenuMap(int width, int height) - : _w(width), _h(height), _grid(width* height, 0) { + : _w(width), _h(height), _grid(size_t(width * height), 0) { } void MenuMap::set(int x, int y, int id) { if (x >= 0 && x < _w && y >= 0 && y < _h) { - _grid[y * _w + x] = id; + _grid[size_t(y * _w + x)] = id; } } @@ -24,7 +24,7 @@ namespace ckitty::terminal { int MenuMap::get(int x, int y) const { if (x < 0 || x >= _w || y < 0 || y >= _h) return 0; - return _grid[y * _w + x]; + return _grid[size_t(y * _w + x)]; } void MenuMap::setWrap(bool x, bool y) {