mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
Add one more line to text viewer (#7528)
This commit is contained in:
parent
ce3f8374a1
commit
4ac35a2e23
5 changed files with 11 additions and 8 deletions
|
@ -40,6 +40,7 @@
|
|||
#define drawFieldLabel(x, y, str) lcdDrawTextAlignedLeft(y, str)
|
||||
|
||||
#define NUM_BODY_LINES (LCD_LINES-1)
|
||||
#define TEXT_VIEWER_LINES NUM_BODY_LINES
|
||||
#define MENU_HEADER_HEIGHT FH
|
||||
|
||||
#define CURVE_SIDE_WIDTH (LCD_H/2)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#define DEFAULT_SCROLLBAR_X (LCD_W-1)
|
||||
#define NUM_BODY_LINES (LCD_LINES-1)
|
||||
#define TEXT_VIEWER_LINES NUM_BODY_LINES
|
||||
#define MENU_HEADER_HEIGHT FH
|
||||
|
||||
#define MODEL_BITMAP_WIDTH 64
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#define FH 20
|
||||
#define NUM_BODY_LINES (MENU_BODY_HEIGHT / FH)
|
||||
#define TEXT_VIEWER_LINES ((MENU_FOOTER_TOP-MENU_HEADER_HEIGHT) / FH)
|
||||
|
||||
#define INVERT_HORZ_MARGIN 2
|
||||
#define INVERT_VERT_MARGIN 1
|
||||
|
|
|
@ -42,7 +42,7 @@ bool menuTextView(event_t event)
|
|||
break;
|
||||
|
||||
case EVT_ROTARY_RIGHT:
|
||||
if (menuVerticalOffset + NUM_BODY_LINES >= lines_count)
|
||||
if (menuVerticalOffset + TEXT_VIEWER_LINES >= lines_count)
|
||||
break;
|
||||
else
|
||||
++menuVerticalOffset;
|
||||
|
@ -55,11 +55,11 @@ bool menuTextView(event_t event)
|
|||
break;
|
||||
}
|
||||
|
||||
for (int i=0; i<NUM_BODY_LINES; i++) {
|
||||
lcd->drawTextMaxWidth(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + i * FH, reusableBuffer.viewText.lines[i], 0, LCD_W - 2 * MENUS_MARGIN_LEFT);
|
||||
for (int i = 0; i < TEXT_VIEWER_LINES; i++) {
|
||||
lcd->drawTextMaxWidth(MENUS_MARGIN_LEFT, MENU_HEADER_HEIGHT + i * FH, reusableBuffer.viewText.lines[i], 0, LCD_W - 2 * MENUS_MARGIN_LEFT);
|
||||
}
|
||||
|
||||
drawVerticalScrollbar(LCD_W-5, 50, 195, menuVerticalOffset, lines_count, NUM_BODY_LINES);
|
||||
drawVerticalScrollbar(LCD_W-5, 50, 195, menuVerticalOffset, lines_count, TEXT_VIEWER_LINES);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -412,7 +412,7 @@ bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen
|
|||
|
||||
constexpr uint32_t TEXT_FILE_MAXSIZE = 2048;
|
||||
|
||||
void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS + 1], int & lines_count)
|
||||
void sdReadTextFile(const char * filename, char lines[TEXT_VIEWER_LINES][LCD_COLS + 1], int & lines_count)
|
||||
{
|
||||
FIL file;
|
||||
int result;
|
||||
|
@ -423,17 +423,17 @@ void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS +
|
|||
char escape_chars[4] = {0};
|
||||
int current_line = 0;
|
||||
|
||||
memclear(lines, NUM_BODY_LINES * (LCD_COLS + 1));
|
||||
memclear(lines, TEXT_VIEWER_LINES * (LCD_COLS + 1));
|
||||
|
||||
result = f_open(&file, filename, FA_OPEN_EXISTING | FA_READ);
|
||||
if (result == FR_OK) {
|
||||
for (unsigned i = 0; i < TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz) == FR_OK && sz == 1 && (lines_count == 0 || current_line - menuVerticalOffset < NUM_BODY_LINES); i++) {
|
||||
for (unsigned i = 0; i < TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz) == FR_OK && sz == 1 && (lines_count == 0 || current_line - menuVerticalOffset < TEXT_VIEWER_LINES); i++) {
|
||||
if (c == '\n') {
|
||||
++current_line;
|
||||
line_length = 0;
|
||||
escape = 0;
|
||||
}
|
||||
else if (c!='\r' && current_line>=menuVerticalOffset && current_line-menuVerticalOffset<NUM_BODY_LINES && line_length<LCD_COLS) {
|
||||
else if (c!='\r' && current_line>=menuVerticalOffset && current_line-menuVerticalOffset<TEXT_VIEWER_LINES && line_length<LCD_COLS) {
|
||||
if (c == '\\' && escape == 0) {
|
||||
escape = 1;
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue