Newtrodit-LCL

This is the channel for the ongoing development of Newtrodit-LCL, a compatibility layer for Newtrodit made by @earth's bird and @earth's god
63 Replies
Dumb Bird
Dumb Bird•2y ago
@earth's god I'm going to make a new branch for LCL called NCurses. I'll be reworking everything to use NCurses, this (if done correctly) will fix many bugs and issues we've faced on the Linux side
anic17
anic17•2y ago
:blobhappy: Glad to hear this Hope we can make it a decent editor
Dumb Bird
Dumb Bird•2y ago
Me too! Also with NCurses setting color at a specific position is possible
anic17
anic17•2y ago
Nice That will help a LOT in performance I've been also thinking of adding 24-bit support if the terminal supports it
Dumb Bird
Dumb Bird•2y ago
Pretty much every major bug we've come across can be fixed by using NCurses That would be nice. NCurses wraps around terminfo we can detect if the terminal supports 24-bit color
anic17
anic17•2y ago
Same for Windows, detecting if 24-bit color is available is simple
Dumb Bird
Dumb Bird•2y ago
Added some really basic NCurses support Had my machine crash way to much though
anic17
anic17•2y ago
Sounds good That doesn't sound good tho xd
Dumb Bird
Dumb Bird•2y ago
NCurses gives many helpful things to the table though Lol I'm not even sure why it crashes my computer, trying to find the issue now
anic17
anic17•2y ago
Can NCurses getch detect shift?
Dumb Bird
Dumb Bird•2y ago
Yes I think so
anic17
anic17•2y ago
Like, differentiate Ctrl-S from Ctrl-Shift-S
Dumb Bird
Dumb Bird•2y ago
Yes NCurses should be able to detect modifier keys separately
anic17
anic17•2y ago
🙂
Dumb Bird
Dumb Bird•2y ago
NCurses also have functions for detecting numpad buttons like it can detect the difference between pressing 1 on a keyboard and 1 on the numpad
anic17
anic17•2y ago
That is also very good
Dumb Bird
Dumb Bird•2y ago
Ok stopped the crashing of my computer part. Now nothing gets displayed, which I also think I know the reason for.
anic17
anic17•2y ago
The only thing I don't like is that we'll have to replace all printf statements to printw
Dumb Bird
Dumb Bird•2y ago
I don't think we need to, do we? It seems printf works
Dumb Bird
Dumb Bird•2y ago
No description
anic17
anic17•2y ago
What about fputs and fwrite
Dumb Bird
Dumb Bird•2y ago
Not sure about them
anic17
anic17•2y ago
What is that depricated message
Dumb Bird
Dumb Bird•2y ago
Something I implemented for debuging To find what parts of the project use old functions that get replaced by NCurses
anic17
anic17•2y ago
Ah ok Nvm I thought it was from curses Sorry lol
Dumb Bird
Dumb Bird•2y ago
No worries I can see the confusion Ah we do have to use printw How would that translate to Windows? Maybe we write a custom print function that checks if you're on Windows or Linux?
anic17
anic17•2y ago
yeah Same arguments as printf, with an #ifdef inside
Dumb Bird
Dumb Bird•2y ago
Yep that's what I was thinking
anic17
anic17•2y ago
With a va_list
Dumb Bird
Dumb Bird•2y ago
What should we call it? nprint, Newtrodit print
anic17
anic17•2y ago
Simply print Ah maybe
Dumb Bird
Dumb Bird•2y ago
is there no print function called print?
anic17
anic17•2y ago
Or printn
Dumb Bird
Dumb Bird•2y ago
yeah print newtrodit makes sense Because anything sent to that function gets sent to the actual Newtrodit display Oh for the record I'm practically shredding the Windows version of newtrodit. I shouldn't need to change how the functions work, but rather their names to be compatible with NCurses naming scheme like gotoxy(x, y) to move(y, x)
anic17
anic17•2y ago
Uh Better keep names as they are And make wrappers for the names Because if a lot of names are changed it will be a lot harder to remember which function does which thing
Dumb Bird
Dumb Bird•2y ago
Ok fixed, sorry bout that.
anic17
anic17•2y ago
It might be easier for you too
Dumb Bird
Dumb Bird•2y ago
@earth's god How do you suppose that I pass the ... to the functions
int printn(const char *format, ...) {
#ifdef _WIN32
printf(format);
#else
printw(format);
#endif
return 0;
}
int printn(const char *format, ...) {
#ifdef _WIN32
printf(format);
#else
printw(format);
#endif
return 0;
}
anic17
anic17•2y ago
With va_list Let me check something
void PrintBottomString(char *str, ...)
{
va_list args;
va_start(args, str);
int xs = XSIZE;
char *printbuf = calloc(xs + 1, sizeof(char));
vsnprintf(printbuf, xs + 1, str, args);

ClearPartial(0, BOTTOM, xs, 1);
printf("%.*s", xs, printbuf); // Don't get out of the buffer
free(printbuf);
return;
}
void PrintBottomString(char *str, ...)
{
va_list args;
va_start(args, str);
int xs = XSIZE;
char *printbuf = calloc(xs + 1, sizeof(char));
vsnprintf(printbuf, xs + 1, str, args);

ClearPartial(0, BOTTOM, xs, 1);
printf("%.*s", xs, printbuf); // Don't get out of the buffer
free(printbuf);
return;
}
That's how I'm declaring PrintBottomString So it would be something like
int printn(const char *format, ...) {
va_list args;
va_start(args, str);
#ifdef _WIN32
printf(format, args);
#else
printw(format, args);
#endif
return 0;
}
int printn(const char *format, ...) {
va_list args;
va_start(args, str);
#ifdef _WIN32
printf(format, args);
#else
printw(format, args);
#endif
return 0;
}
Or even differently, what about implementing printn as a macro?
#ifdef _WIN32
#define printn printf
#else
#define printn printw
#endif
#ifdef _WIN32
#define printn printf
#else
#define printn printw
#endif
@earth's bird Maybe it's a bit hacky but it works
Dumb Bird
Dumb Bird•2y ago
Actually I'll just define printn in the core files so I don't actually need to check if _WIN32 is defined
anic17
anic17•2y ago
Using macros code would be substantially reduced
Dumb Bird
Dumb Bird•2y ago
Yes I am going to use marcos
anic17
anic17•2y ago
marcos
Dumb Bird
Dumb Bird•2y ago
I'm trying to type fast
anic17
anic17•2y ago
btw feel free to push any changes to the repo when done
Dumb Bird
Dumb Bird•2y ago
I'm going to push it all to a separate branch for now (once basic support and simple bugs have been patched)
anic17
anic17•2y ago
Alright Yeah later we can compare and merge see ya I'm going dinner
Dumb Bird
Dumb Bird•2y ago
Cya
anic17
anic17•2y ago
i'll come back in ~45 mins
Dumb Bird
Dumb Bird•2y ago
Lets hope I don't blow up my computer while your gone
anic17
anic17•2y ago
I'm back You can do the same with gotoxy() and move
#define gotoxy(x,y) move(x,y)
#define gotoxy(x,y) move(x,y)
Dumb Bird
Dumb Bird•2y ago
#define gotoxy(x,y) move(y, x)
#define gotoxy(x,y) move(y, x)
anic17
anic17•2y ago
y and x ? move(y, x) ? messages aren't sending nvm
Dumb Bird
Dumb Bird•2y ago
Yes
anic17
anic17•2y ago
just read the docs
Dumb Bird
Dumb Bird•2y ago
move takes in y first
anic17
anic17•2y ago
ncurses being weird part 1
Dumb Bird
Dumb Bird•2y ago
lol
To reduce repeated code, I'm considering to create a new file called newtrodit_shared.c or newtrodit_func_shared.c which will have functions that exactly the same on linux and win32
I'm probably going to go through with this idea. I'll most likely call the file newtrodit_func_shared
anic17
anic17•2y ago
Go ahead Less like of code is a better codebase because it's more maintainable @earth's bird just to know, are you doing changes to newtrodit.c?
Dumb Bird
Dumb Bird•2y ago
Some but not many Like I have to initiate NCurses in the main function but that’s about all @earth's god
anic17
anic17•2y ago
Alright just making sure as I modified the main file quite a bit lately
Dumb Bird
Dumb Bird•2y ago
Can't work much on LCL until the weekend rolls 'round
anic17
anic17•2y ago
Same I'm quite busy these days bc exams and homework I tried fixing a bug yesterday related to horizontal scrolling but no luck I don't get the algorithm right Already tried thinking the algorithm with paper and pencil and still didn't work as expected