second attempt
This commit is contained in:
parent
e6ba036c73
commit
17ccbacd8d
1 changed files with 37 additions and 12 deletions
45
testline.c
45
testline.c
|
@ -16,26 +16,27 @@ typedef struct InfoState {
|
||||||
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(" ");
|
putchar(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int lcd_print_between(char* pos1, char* pos2) {
|
int lcd_print_between(char* str, int pos1, int pos2) {
|
||||||
//int i = 0;
|
//int i = 0;
|
||||||
int va = 0;
|
int va = 0;
|
||||||
|
|
||||||
char* p = pos1;
|
char* p = str+pos1;
|
||||||
//int slen = strlen(str);
|
//int slen = strlen(str);
|
||||||
while (p < pos2) {
|
while (p < str+pos2) {
|
||||||
if (*p != '\n' && *p != '\r') {
|
if (*p != '\n' && *p != '\r') {
|
||||||
//lcd.print(*(p++));
|
//lcd.print(*(p++));
|
||||||
putchar(*(p++));
|
putchar(*p);
|
||||||
++va;
|
++va;
|
||||||
} //else
|
} //else
|
||||||
//if (i == 0){ ++i; } else
|
//if (i == 0){ ++i; } else
|
||||||
//{
|
//{
|
||||||
// break;
|
// break;
|
||||||
//}
|
//}
|
||||||
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (va < 15) {
|
if (va < 15) {
|
||||||
|
@ -44,6 +45,7 @@ int lcd_print_between(char* pos1, char* pos2) {
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
putchar('!');
|
||||||
return va;
|
return va;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +78,9 @@ list_t* aux_gen_wrap_list(list_t* wrap, char* text) {
|
||||||
}
|
}
|
||||||
++curr;
|
++curr;
|
||||||
}
|
}
|
||||||
|
if (list_rpush(wrap, list_node_new((int)(curr-text))) == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return wrap;
|
return wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,19 +100,37 @@ void initInfoState(InfoState* st, char* text) {
|
||||||
st->pos2 = st->pos3 = NULL;
|
st->pos2 = st->pos3 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initInfoScreen(InfoState* st, char* text) {
|
int initInfoScreen(InfoState* st, char* text) {
|
||||||
initInfoState(st, text);
|
initInfoState(st, text);
|
||||||
|
printf("%d\n", st->wrap->len);
|
||||||
|
int retn = 0;
|
||||||
//lcd.setCursor(0, 0);
|
//lcd.setCursor(0, 0);
|
||||||
if ((st->pos2 = list_iterator_next(st->it))) {
|
if ((st->pos2 = list_iterator_next(st->it))) {
|
||||||
//printf("hello\n");
|
//printf("hello\n");
|
||||||
printf("%d\n", st->pos2->val);
|
//printf("%d\n", st->pos2->val);
|
||||||
int tmp = lcd_print_between(st->info, st->info+(int)st->pos2->val);
|
int tmp = lcd_print_between(st->info, 0, (int)st->pos2->val);
|
||||||
printf("%d\n", tmp);
|
//printf("%d\n", tmp);
|
||||||
|
//printf("%d\n", st->wrap->len);
|
||||||
|
if ((st->pos3 = list_iterator_next(st->it))) {
|
||||||
|
printf("\n");
|
||||||
|
//printf("%d\n", st->pos2->val);
|
||||||
|
//printf("%d\n", st->pos3->val);
|
||||||
|
int tmp = lcd_print_between(st->info, (int)st->pos2->val, (int)st->pos3->val);
|
||||||
|
//printf("%d\n", tmp);
|
||||||
|
//printf("%d\n", st->wrap->len);
|
||||||
|
} else {
|
||||||
|
printf("\n");
|
||||||
|
lcd_blank_line();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
retn = 1;
|
||||||
|
}
|
||||||
|
return retn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int scrollDown(InfoState* st) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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
|
||||||
|
@ -177,6 +200,8 @@ 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
|
// 0 1516 32
|
||||||
|
char* s2 = " ba\n ab";
|
||||||
|
// 0 11
|
||||||
list_t *wrap = list_new();
|
list_t *wrap = list_new();
|
||||||
wrap = aux_gen_wrap_list(wrap, cinfo);
|
wrap = aux_gen_wrap_list(wrap, cinfo);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue