first attempt
This commit is contained in:
parent
79a8c00636
commit
e6ba036c73
|
@ -0,0 +1,13 @@
|
||||||
|
#Sat Jan 06 23:52:39 GMT+08:00 2024
|
||||||
|
binary_fname=
|
||||||
|
run_mode=0
|
||||||
|
use_cmake=false
|
||||||
|
sm_names=testline.c src/list/src/list.c src/list/src/list_iterator.c src/list/src/list_node.c
|
||||||
|
qmake_cmd=export PATH\=(c4droid\:GCCROOT)qt/bin/\:$PATH\nqmake -spec android-g++
|
||||||
|
cmake_cmd=cmake .
|
||||||
|
prepare_cmds=export PATH\=/busybox-virtual\:(c4droid\:DATADIR)\:(c4droid\:GCCROOT)bin\:(c4droid\:GCCROOT)(c4droid\:PREFIX)/bin/\:$PATH\nexport CC\="(c4droid\:PREFIX)-gcc (c4droid\:PIE) (c4droid\:MAKEMODEARGS)"\nexport CXX\="(c4droid\:PREFIX)-g++ (c4droid\:PIE) (c4droid\:MAKEMODEARGS)"\nexport SHELL\="(c4droid\:DATADIR)sh"\ncd (c4droid\:CURSRCDIR)
|
||||||
|
comp_mode=4
|
||||||
|
make_cmd=make CC\="$CC" CXX\="$CXX" SHELL\="$SHELL"
|
||||||
|
conf_patch=true
|
||||||
|
conf_cmd=export PATH\=/busybox-virtual\:(c4droid\:DATADIR)\:(c4droid\:GCCROOT)bin\:(c4droid\:GCCROOT)(c4droid\:PREFIX)/bin/\:$PATH\nexport CFLAGS\="-Os -s (c4droid\:PIE)"\nexport CXXFLAGS\="-Os -s (c4droid\:PIE)"\nexport SHELL\="(c4droid\:DATADIR)sh"\nexport CONFIG_SHELL\="sh"\nexport PKG_CONFIG_PATH\=(c4droid\:GCCROOT)(c4droid\:PREFIX)/lib/pkgconfig\ncd (c4droid\:CURSRCDIR)\nfind . -exec touch {} \\;\ncd (c4droid\:BUILDDIR)\n(c4droid\:CURSRCDIR)/configure --host\=(c4droid\:PREFIX) --prefix\=(c4droid\:GCCROOT)(c4droid\:PREFIX) CFLAGS\="$CFLAGS" CXXFLAGS\="$CXXFLAGS" --build\=i686-linux --disable-shared --enable-static\nmake SHELL\="$SHELL"\nmake install SHELL\="$SHELL"
|
||||||
|
conf_internal=false
|
118
testline.c
118
testline.c
|
@ -2,62 +2,50 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "src/list/src/list.h"
|
#include "src/list/src/list.h"
|
||||||
|
|
||||||
/*
|
|
||||||
typedef struct InfoState {
|
typedef struct InfoState {
|
||||||
char* info;
|
char* info;
|
||||||
int len;
|
list_node_t *pos1, *pos2, *pos3;
|
||||||
int fullLines;
|
list_t *wrap;
|
||||||
int Nlines;
|
list_iterator_t *it;
|
||||||
int lastlinelen;
|
//list_node_t *node;
|
||||||
char *pos1, *pos2, *pos3;
|
|
||||||
list_t* wrap;
|
|
||||||
} InfoState;
|
} InfoState;
|
||||||
|
|
||||||
void initInfoState(InfoState* st, char* text) {
|
|
||||||
st->info = text;
|
|
||||||
st->len = strlen(text);
|
|
||||||
st->fullLines = st->len / 15;
|
|
||||||
st->Nlines = (st->len + 14) / 15;
|
|
||||||
st->lastlinelen = st->len % 15;
|
|
||||||
st->pos1 = text;
|
|
||||||
st->pos2 = text;
|
|
||||||
st->pos3 = text;
|
|
||||||
st->wrap = list_new();
|
|
||||||
char* tmp = text;
|
|
||||||
//list_node_t *c = list_rpush(st->wrap, list_node_new("c"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcd_blank_line() {
|
void lcd_blank_line() {
|
||||||
for (int i = 0; i < 15; ++i) {
|
for (int i = 0; i < 15; ++i) {
|
||||||
lcd.print(' ');
|
//lcd.print(' ');
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initInfoScreen(InfoState* st, char* text) {
|
int lcd_print_between(char* pos1, char* pos2) {
|
||||||
initInfoState(st, text);
|
//int i = 0;
|
||||||
lcd.setCursor(0, 0);
|
int va = 0;
|
||||||
if (*(st->pos1) == '\n' || *(st->pos1) == '\r') {
|
|
||||||
lcd_blank_line();
|
char* p = pos1;
|
||||||
++st->pos1;
|
//int slen = strlen(str);
|
||||||
++st->pos2;
|
while (p < pos2) {
|
||||||
} else {
|
if (*p != '\n' && *p != '\r') {
|
||||||
st->pos2 += lcd_print_line(st->pos1);
|
//lcd.print(*(p++));
|
||||||
|
putchar(*(p++));
|
||||||
|
++va;
|
||||||
|
} //else
|
||||||
|
//if (i == 0){ ++i; } else
|
||||||
|
//{
|
||||||
|
// break;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
lcd.setCursor(0, 1);
|
|
||||||
if ((*(st->pos2) == '\n' || *(st->pos2) == '\r') && *(st->pos2 - 1) == *(st->pos2)) {
|
if (va < 15) {
|
||||||
lcd_blank_line();
|
for (int j = 15 - va; j > 0; --j) {
|
||||||
} else {
|
//lcd.print(' ');
|
||||||
lcd_print_line(st->pos2);
|
putchar(' ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
return va;
|
||||||
//Serial.println(String("pos1: ") + st->pos1);
|
|
||||||
//Serial.println(String("pos2: ") + st->pos2);
|
|
||||||
Serial.println("init");
|
|
||||||
Serial.print(st->pos1-st->info);
|
|
||||||
Serial.println(String(" ")+(st->pos2-st->info));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
list_t* aux_gen_wrap_list(list_t* wrap, char* text) {
|
list_t* aux_gen_wrap_list(list_t* wrap, char* text) {
|
||||||
if (wrap == NULL) {
|
if (wrap == NULL) {
|
||||||
|
@ -66,7 +54,7 @@ list_t* aux_gen_wrap_list(list_t* wrap, char* text) {
|
||||||
char* curr = text;
|
char* curr = text;
|
||||||
int suf = 0;
|
int suf = 0;
|
||||||
list_node_t *node;
|
list_node_t *node;
|
||||||
if (list_rpush(wrap, list_node_new(0)) == NULL) {
|
if (list_rpush(wrap, list_node_new(-1)) == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while (*curr != '\0') {
|
while (*curr != '\0') {
|
||||||
|
@ -91,6 +79,36 @@ list_t* aux_gen_wrap_list(list_t* wrap, char* text) {
|
||||||
return wrap;
|
return wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initInfoState(InfoState* st, char* text) {
|
||||||
|
st->info = text;
|
||||||
|
//st->len = strlen(text);
|
||||||
|
//st->fullLines = st->len / 15;
|
||||||
|
//st->Nlines = (st->len + 14) / 15;
|
||||||
|
//st->lastlinelen = st->len % 15;
|
||||||
|
//st->pos1 = text;
|
||||||
|
//st->pos2 = text;
|
||||||
|
//st->pos3 = text;
|
||||||
|
st->wrap = list_new();
|
||||||
|
st->wrap = aux_gen_wrap_list(st->wrap, st->info);
|
||||||
|
st->it = list_iterator_new(st->wrap, LIST_HEAD);
|
||||||
|
st->pos1 = list_iterator_next(st->it);
|
||||||
|
st->pos2 = st->pos3 = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initInfoScreen(InfoState* st, char* text) {
|
||||||
|
initInfoState(st, text);
|
||||||
|
//lcd.setCursor(0, 0);
|
||||||
|
if ((st->pos2 = list_iterator_next(st->it))) {
|
||||||
|
//printf("hello\n");
|
||||||
|
printf("%d\n", st->pos2->val);
|
||||||
|
int tmp = lcd_print_between(st->info, st->info+(int)st->pos2->val);
|
||||||
|
printf("%d\n", tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Separate a substring that can be printed on one line, and return the
|
Separate a substring that can be printed on one line, and return the
|
||||||
original string position corresponding to the end of the substring.
|
original string position corresponding to the end of the substring.
|
||||||
|
@ -158,20 +176,28 @@ char* aux_sub_line_rev(char* str, char substr[16]) {
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
char* cinfo = "Far far away, a\n\nbehind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.";
|
char* cinfo = "Far far away, a\n\nbehind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.";
|
||||||
|
// 0 1516 32
|
||||||
list_t *wrap = list_new();
|
list_t *wrap = list_new();
|
||||||
wrap = aux_gen_wrap_list(wrap, cinfo);
|
wrap = aux_gen_wrap_list(wrap, cinfo);
|
||||||
|
|
||||||
list_node_t *node;
|
list_node_t *node;
|
||||||
list_iterator_t *it = list_iterator_new(wrap, LIST_HEAD);
|
list_iterator_t *it = list_iterator_new(wrap, LIST_HEAD);
|
||||||
|
|
||||||
|
InfoState st;
|
||||||
|
initInfoScreen(&st, cinfo);
|
||||||
|
|
||||||
|
/*
|
||||||
while ((node = list_iterator_next(it))) {
|
while ((node = list_iterator_next(it))) {
|
||||||
printf("%d\n", (unsigned int)(node->val));
|
printf("%d\n", (unsigned int)(node->val));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
if ((node = list_iterator_next(it))) {
|
if ((node = list_iterator_next(it))) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((node = list_iterator_next(it))) {
|
||||||
|
//if (node->val == -1) {
|
||||||
char* p = cinfo;
|
char* p = cinfo;
|
||||||
list_node_t *test;
|
list_node_t *test;
|
||||||
while (*p != '\0') {
|
while (*p != '\0') {
|
||||||
|
|
Loading…
Reference in New Issue