Made the rtb only use 1 string and made the Nomai Branches have a start pos and use a beter cordent system
This commit is contained in:
@@ -34,7 +34,6 @@ unsigned char __Close__ = 0;
|
||||
|
||||
void programClose(int sig) {
|
||||
term_threaded_input_stop();
|
||||
term_enable_cursor();
|
||||
__Close__ = 1;
|
||||
}
|
||||
|
||||
@@ -57,41 +56,36 @@ void SetRichTextBox(richTextBox* rtb, char* text, int len,
|
||||
char* p = text;
|
||||
unsigned char found = 0;
|
||||
rtb->stringCount = 5;
|
||||
rtb->text = text;
|
||||
int sizeOfString = 0;
|
||||
for(int i = 0; i < len; i++) {
|
||||
sizeOfString = i - textOffset;
|
||||
|
||||
if(p[i] == '\n') {
|
||||
// This means that it will start splitting strings
|
||||
found = 1;
|
||||
|
||||
//p[i] = '\0'; // Sets this to be the end of the string
|
||||
|
||||
//Add the address to the cstring
|
||||
if(lineCount == 5) {
|
||||
break;
|
||||
}
|
||||
|
||||
rtb->textBox[lineCount] = tart_cstring(p + textOffset,
|
||||
sizeOfString, rtb->cell);
|
||||
textOffset = i + 1; // Sets the start of the next string.
|
||||
lineCount++;
|
||||
}
|
||||
}
|
||||
tart_cstring_free(&rtb->textBox[lineCount]);
|
||||
rtb->textBox[lineCount] = tart_cstring(p + textOffset,
|
||||
strlen(p), rtb->cell);
|
||||
|
||||
}
|
||||
|
||||
void drawTextBox(struct tart_window* window, richTextBox* rtb, tart_byte id) {
|
||||
struct tart_buffer* sb = tart_get_buffer(window, id);
|
||||
// This makes sure that we dont go outside of memeery with the string count.
|
||||
for (int lineNo = 0; lineNo < rtb->stringCount; lineNo++) {
|
||||
tart_draw_cstring_position(sb,
|
||||
rtb->textBox[lineNo],
|
||||
(struct tart_vec2){rtb->pos.x,rtb->pos.y + lineNo});
|
||||
int lineNo = 0;
|
||||
int lineStart = 0;
|
||||
for(int i = 0; i < strlen(rtb->text); i++) {
|
||||
if(rtb->text[i] == '\n') {
|
||||
rtb->textBox[0] = tart_cstring(
|
||||
&rtb->text[0]+lineStart,
|
||||
i - lineStart,
|
||||
NULL_CELL);
|
||||
tart_draw_cstring_position(sb,
|
||||
rtb->textBox[0],
|
||||
(struct tart_vec2){rtb->pos.x, rtb->pos.y+lineNo});
|
||||
tart_cstring_free(&rtb->textBox[0]);
|
||||
lineNo++;
|
||||
lineStart = i + 1;
|
||||
}
|
||||
}
|
||||
rtb->textBox[0] = tart_cstring(
|
||||
&rtb->text[0]+lineStart,
|
||||
strlen(rtb->text) - lineStart,
|
||||
NULL_CELL);
|
||||
tart_draw_cstring_position(sb,
|
||||
rtb->textBox[0],
|
||||
(struct tart_vec2){rtb->pos.x, rtb->pos.y+lineNo});
|
||||
tart_cstring_free(&rtb->textBox[0]);
|
||||
}
|
||||
|
||||
//############ Init Commands ############
|
||||
@@ -124,6 +118,10 @@ int main (int argc, char *argv[]) {
|
||||
char commandInput[255] = "";
|
||||
unsigned char keyPressed = 0;
|
||||
|
||||
branch b = {
|
||||
.startPos = (struct tart_vec2){term_current_size().x/2,term_current_size().y- 10},
|
||||
};
|
||||
|
||||
|
||||
// Window Createion
|
||||
struct tart_window window = tart_create_window();
|
||||
@@ -260,7 +258,8 @@ int main (int argc, char *argv[]) {
|
||||
drawTextBox(&window, &inputRtb, 0);
|
||||
|
||||
|
||||
DrawBranch(NULL, &window, 0);
|
||||
|
||||
DrawBranch(&b, &window, 0);
|
||||
|
||||
tart_draw_window(&window, 0);
|
||||
if(mode == COMMAND_MODE) {
|
||||
@@ -285,5 +284,6 @@ int main (int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
tart_destroy_window(&window);
|
||||
term_enable_cursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user