rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
files_screen.c File Reference

FILES: the state, the requests to the card's task, the footer's operations and the screen's interface (files_screen.h). files_draw.c draws the screen, files_events.c takes its touch events, and files_int.h is what the three share. More...

#include "files_screen.h"
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include "card_tree.h"
#include "fm_name.h"
#include "fm_ops.h"
#include "log_name.h"
#include "log_select.h"
#include "log_viewer_screen.h"
#include "ui_screen.h"
#include "ui_text.h"
#include "ui_textkey.h"
#include "files_int.h"

Data Structures

struct  place_t
 What of a pane RESCAN's answer keeps: its top row on screen, copied before the answer replaces the page. The selection is kept by fm_tree_page(), by name. More...

Enumerations

enum  need_t { NEED_NONE = 0 , NEED_PAGE , NEED_UP , NEED_ENTER }
 A pane's request waiting for the card's task. More...

Functions

static void read_bench (void)
 The bench as the gate and the rules see it now: the io's, ARMED also when the band says so, and the log folders in force.
static bool io_ok (void)
 Whether the io can take requests.
static void keep_arg (char to[FM_NAME_BUF], const char *from)
 Copy from into the message's argument to, "" for NULL.
void fs_say (bool ok, ui_text_id_t id, const char *a, const char *b)
 The message line says id, with up to two names.
void fs_say_err (fm_err_t err, const char *name)
 The message line says why err, for name (fs_err_text()).
void fs_quiet (void)
 The message line says nothing.
const char * fs_message (char *buf, size_t n)
 The message line in the language showing.
void fs_err_text (fm_err_t err, const char *name, char *out, size_t n)
 The words of a refusal or a failure, for name.
static bool submit (void)
 Hand s.req to the card's task, the log folders in force with it.
static void want (int i, need_t need, fm_go_t go)
 Pane i is to be read: a page, the folder above, or the folder on its selected row. A newer wish replaces the one waiting.
static void start_panes (void)
 Both panes in their start folders, nothing read: the card's root and USER LOG FOLDER.
static void select_name (int i, const char *name)
 Select name on pane i's page when it is there, and scroll the row into sight.
static int place_of (const fm_tree_t *t, const fm_entry_t *e)
 The row of pane t where entry e stands in the pane's order: e's own row, or the first row that ranks behind it.
static void place_note (int i, place_t *p)
 Pane i's place, as RESCAN keeps it.
static void place_keep (int i, const place_t *p)
 RESCAN's answer for pane i keeps the pane's place: the entry that was the top row on screen stays the top row, and the selection stays on its entry (fm_tree_page() keeps it by name).
static void take_pane (void)
 The answer of a pane's request: the pane as the card's task read it. A pane read from another card than the other's sends both back to their start folders.
static void take_job (void)
 The answer of a job: the message, and both panes read again.
static void take_answer (void)
 The answer of the request under way, once it is in.
static void send_next (void)
 The next pane's request out, when nothing is under way.
static void pump (void)
 Take the answer that is in, then send what waits.
const fm_entry_t * fs_selected (void)
 The selected entry of the active pane.
bool fs_paged (int i)
 Whether a pane's folder holds more than its page.
void fs_clamp_scroll (int i)
 Pane i's scroll held to its rows.
void fs_bar_thumb (int i, int *y, int *h)
 The scroll bar's thumb of pane i.
int fs_bar_scroll_at (int i, int top)
 The scroll of pane i that puts the thumb's top nearest top.
static bool logs_tab_of (const char *dir, log_viewer_tab_t *tab)
 The LOGS tab whose folder dir is, when LOGS shows the files of it.
static bool logs_shows (const char *dir, const fm_entry_t *e)
 Whether LOGS shows entry e of folder dir: a .csv file, or a report, in the folder of one of its tabs. The names are the ones LOGS' list holds (log_select_lists()); a report is the name the list here labels one (fm_kind_of(), log_report_number()).
bool fs_foot_live (fs_foot_t b, fm_err_t *why)
 Whether footer button b takes a press now, and why not.
static void start_job (fm_err_t err, const char *name)
 Start a job of s.req, filled by an fm_job_*() call that answered err: its box, or the refusal.
static void open_in_logs (const fm_entry_t *e)
 OPEN on a file LOGS shows: LOGS, on that file's tab, with it open. A file LOGS' list does not hold now, one gone from the card since this list was read, stays here with FM_E_NOT_FOUND.
void fs_foot (fs_foot_t b)
 Act on footer button b: a tap on it, live or dimmed.
void fs_turn (int i, fm_go_t go, bool up)
 Read another page of pane i, or the folder above it.
void fs_row_tap (int i, int row)
 A tap on row row of pane i: the pane active and the row selected; a tap on the selected row of the active pane opens it.
void fs_delete_doomed (void)
 The DELETE question's DELETE: the job that deletes it.
void fs_new_name (bool folder)
 NEW's choice: the keyboard for the new entry's name.
void fs_name_typed (const char *name)
 The keyboard closed with name: the job that makes or renames.
void fs_job_cancel (void)
 CANCEL on the progress box.
void files_size_text (char *out, size_t n, uint64_t bytes)
 A size as the panes and INFO write it, no space before the unit: "300B", "4kB", "3.0MB" from 1MiB, "8.00GB" from 1GiB. The units are binary: 1kB is 1024 bytes.
void files_time_text (char *out, size_t n, int64_t mtime)
 A time as INFO writes it: "2024-05-17 12:34", read as UTC, or "" for -1. INFO hands it the stamp moved into the zone SETUP holds (wall_local_s()), and writes FM_INFO_NO_TIME for a stamp wall_stamp_known() refuses.
void files_screen_set_io (const files_io_t *io)
 Point the screen at the card's task. NULL leaves it without one: both panes show no card.
files_view_t files_screen_view (void)
 The view on top.
int files_screen_active (void)
 The active pane: the one OPEN, RENAME, DELETE, NEW and INFO act in, and whose entry COPY and MOVE take to the other.
const fm_tree_t * files_screen_pane (int i)
 A pane as last read.
int files_screen_scroll (int i)
 A pane's first row on screen.
const char * files_screen_message (void)
 The message line: the last result or refusal, worded in the language showing; "" for none. The write gate's sentence, drawn while the line holds nothing, is not part of it.
bool files_screen_busy (void)
 Whether a request is under way on the card's task.
void files_screen_invalidate (void)
 Repaint the cached chrome into every framebuffer.
static void reset (void)
 The screen as a start leaves it: the card's root on the left, USER LOG FOLDER on the right, neither read. The io stays; a request under way stays the card's task's.
static void enter (void)
 On the way in: both panes read, from their first pages the first time and as they were left after that, the slot looked at first.
static void leave (void)
 On the way out: the keyboard and the boxes close; a job under way goes on, and its box shows again on the way back in.
static void tick (float dt_s)
 Time passed: the answer taken when it is in, the progress and the gate followed for the drawing.
static bool back (void)
 The home tag: a box or the keyboard closes, a job's box cancels a copy and stays; with the panes on top the screen is left.
const ui_screen_t * files_screen (void)
 The screen.

Variables

fs_state_t fs_s
 The screen's state; files_int.h names it s.
static need_t s_need [2]
 What each pane waits for (need_t), beside s.need_go.
static const ui_screen_t s_screen
 The screen's table for the router.

Detailed Description

FILES: the state, the requests to the card's task, the footer's operations and the screen's interface (files_screen.h). files_draw.c draws the screen, files_events.c takes its touch events, and files_int.h is what the three share.

Every card call of the screen is a request (fm_req.h) on the card's task. The listings wait in a queue of one per pane; INFO and a job go out when nothing else is under way. An answer is taken in tick(), and a job's answer reads both panes again, since a copy or a move changes the other pane's folder too.

SPDX-License-Identifier: MIT

Enumeration Type Documentation

◆ need_t

enum need_t

A pane's request waiting for the card's task.

Enumerator
NEED_PAGE 

a page: need_go

NEED_UP 

the folder above

NEED_ENTER 

the folder on the selected row

Function Documentation

◆ back()

bool back ( void )
static

The home tag: a box or the keyboard closes, a job's box cancels a copy and stays; with the panes on top the screen is left.

Returns
true when the screen went up a level of its own

◆ files_screen()

const ui_screen_t * files_screen ( void )

The screen.

Returns
its table

◆ files_screen_active()

int files_screen_active ( void )

The active pane: the one OPEN, RENAME, DELETE, NEW and INFO act in, and whose entry COPY and MOVE take to the other.

Returns
0 for the left pane, 1 for the right

◆ files_screen_busy()

bool files_screen_busy ( void )

Whether a request is under way on the card's task.

Returns
true until its answer is taken

◆ files_screen_message()

const char * files_screen_message ( void )

The message line: the last result or refusal, worded in the language showing; "" for none. The write gate's sentence, drawn while the line holds nothing, is not part of it.

Returns
the line, in a buffer the next call overwrites

◆ files_screen_pane()

const fm_tree_t * files_screen_pane ( int i)

A pane as last read.

Parameters
i0 for the left pane, 1 for the right
Returns
the pane, or NULL for another i

◆ files_screen_scroll()

int files_screen_scroll ( int i)

A pane's first row on screen.

Parameters
i0 for the left pane, 1 for the right
Returns
the row's index on the page, 0 for another i

◆ files_screen_set_io()

void files_screen_set_io ( const files_io_t * io)

Point the screen at the card's task. NULL leaves it without one: both panes show no card.

Parameters
iothe io, copied

◆ files_screen_view()

files_view_t files_screen_view ( void )

The view on top.

Returns
the view

◆ files_size_text()

void files_size_text ( char * out,
size_t n,
uint64_t bytes )

A size as the panes and INFO write it, no space before the unit: "300B", "4kB", "3.0MB" from 1MiB, "8.00GB" from 1GiB. The units are binary: 1kB is 1024 bytes.

Parameters
outtakes the text
nbytes at out
bytesthe size

◆ files_time_text()

void files_time_text ( char * out,
size_t n,
int64_t mtime )

A time as INFO writes it: "2024-05-17 12:34", read as UTC, or "" for -1. INFO hands it the stamp moved into the zone SETUP holds (wall_local_s()), and writes FM_INFO_NO_TIME for a stamp wall_stamp_known() refuses.

Parameters
outtakes the text
nbytes at out
mtimeseconds since 1970-01-01, or -1

◆ fs_bar_scroll_at()

int fs_bar_scroll_at ( int i,
int top )

The scroll of pane i that puts the thumb's top nearest top.

Parameters
ithe pane
topthe thumb's top the finger asks for
Returns
the first row on screen

◆ fs_bar_thumb()

void fs_bar_thumb ( int i,
int * y,
int * h )

The scroll bar's thumb of pane i.

Parameters
ithe pane
ytakes its top
htakes its height

◆ fs_clamp_scroll()

void fs_clamp_scroll ( int i)

Pane i's scroll held to its rows.

Parameters
ithe pane

◆ fs_err_text()

void fs_err_text ( fm_err_t err,
const char * name,
char * out,
size_t n )

The words of a refusal or a failure, for name.

Parameters
errthe answer
namethe entry's name, for the formats that name it
outtakes the sentence
nbytes at out

◆ fs_foot()

void fs_foot ( fs_foot_t b)

Act on footer button b: a tap on it, live or dimmed.

Parameters
bthe button

◆ fs_foot_live()

bool fs_foot_live ( fs_foot_t b,
fm_err_t * why )

Whether footer button b takes a press now, and why not.

Parameters
bthe button
whytakes the refusal, FM_OK when it takes one; may be NULL
Returns
true when it acts

◆ fs_message()

const char * fs_message ( char * buf,
size_t n )

The message line in the language showing.

Parameters
buftakes the line
nbytes at buf, FS_MSG_MAX for the longest
Returns
buf, "" for no message; "" also for a NULL buf or a zero n

◆ fs_name_typed()

void fs_name_typed ( const char * name)

The keyboard closed with name: the job that makes or renames.

Parameters
namethe name typed

◆ fs_new_name()

void fs_new_name ( bool folder)

NEW's choice: the keyboard for the new entry's name.

Parameters
foldera folder, else an empty text file

◆ fs_paged()

bool fs_paged ( int i)

Whether a pane's folder holds more than its page.

Parameters
ithe pane
Returns
true when PREV and NEXT show

◆ fs_row_tap()

void fs_row_tap ( int i,
int row )

A tap on row row of pane i: the pane active and the row selected; a tap on the selected row of the active pane opens it.

Parameters
ithe pane
rowthe row's index on the page

◆ fs_say()

void fs_say ( bool ok,
ui_text_id_t id,
const char * a,
const char * b )

The message line says id, with up to two names.

The line keeps the ID and the names, and fs_message() words it in the language showing, so a change of SET_LANGUAGE rewords it.

Parameters
oka result, not a refusal
idthe text: FM_COPIED, FM_MOVED, LOG_DELETED and FM_MADE format a, FM_RENAMED a and b; any other is shown as it is
athe first name, or NULL
bthe second name, or NULL

◆ fs_say_err()

void fs_say_err ( fm_err_t err,
const char * name )

The message line says why err, for name (fs_err_text()).

Parameters
errthe answer
namethe entry's name, or NULL

◆ fs_selected()

const fm_entry_t * fs_selected ( void )

The selected entry of the active pane.

Returns
the entry, or NULL for none

◆ fs_turn()

void fs_turn ( int i,
fm_go_t go,
bool up )

Read another page of pane i, or the folder above it.

Parameters
ithe pane
gowhich page; FM_GO_FIRST with up for the folder above
upgo up one folder

◆ io_ok()

bool io_ok ( void )
static

Whether the io can take requests.

Returns
true with an io that has submit() and idle()

◆ keep_arg()

void keep_arg ( char to[FM_NAME_BUF],
const char * from )
static

Copy from into the message's argument to, "" for NULL.

Parameters
tothe argument, FM_NAME_BUF bytes
fromthe name, or NULL

◆ logs_shows()

bool logs_shows ( const char * dir,
const fm_entry_t * e )
static

Whether LOGS shows entry e of folder dir: a .csv file, or a report, in the folder of one of its tabs. The names are the ones LOGS' list holds (log_select_lists()); a report is the name the list here labels one (fm_kind_of(), log_report_number()).

Parameters
dirthe entry's folder
ethe entry
Returns
true when OPEN hands it to LOGS

◆ logs_tab_of()

bool logs_tab_of ( const char * dir,
log_viewer_tab_t * tab )
static

The LOGS tab whose folder dir is, when LOGS shows the files of it.

Parameters
dira folder
tabtakes the tab
Returns
true for the folder of ROOT, USER or BENCH

◆ open_in_logs()

void open_in_logs ( const fm_entry_t * e)
static

OPEN on a file LOGS shows: LOGS, on that file's tab, with it open. A file LOGS' list does not hold now, one gone from the card since this list was read, stays here with FM_E_NOT_FOUND.

Parameters
ethe entry

◆ place_keep()

void place_keep ( int i,
const place_t * p )
static

RESCAN's answer for pane i keeps the pane's place: the entry that was the top row on screen stays the top row, and the selection stays on its entry (fm_tree_page() keeps it by name).

A top row gone from the card leaves the entry now at its place on top. A selected entry gone from the card, or moved off the page, leaves nothing selected, as after a DELETE: MOVE and RENAME act on the selection without a question, so no other entry takes it. The scroll is held to the rows after (fs_clamp_scroll()).

Parameters
ithe pane
pthe place before the answer (place_note())

◆ place_note()

void place_note ( int i,
place_t * p )
static

Pane i's place, as RESCAN keeps it.

Parameters
ithe pane
ptakes the place

◆ place_of()

int place_of ( const fm_tree_t * t,
const fm_entry_t * e )
static

The row of pane t where entry e stands in the pane's order: e's own row, or the first row that ranks behind it.

Parameters
tthe pane
ethe entry
Returns
the row; t->held when every row ranks ahead of e

◆ select_name()

void select_name ( int i,
const char * name )
static

Select name on pane i's page when it is there, and scroll the row into sight.

Parameters
ithe pane
namethe name

◆ start_job()

void start_job ( fm_err_t err,
const char * name )
static

Start a job of s.req, filled by an fm_job_*() call that answered err: its box, or the refusal.

Parameters
errthe start's answer
namethe entry's name, for a refusal's words

◆ submit()

bool submit ( void )
static

Hand s.req to the card's task, the log folders in force with it.

Returns
true when it is under way

◆ tick()

void tick ( float dt_s)
static

Time passed: the answer taken when it is in, the progress and the gate followed for the drawing.

Parameters
dt_sseconds since the last tick

◆ want()

void want ( int i,
need_t need,
fm_go_t go )
static

Pane i is to be read: a page, the folder above, or the folder on its selected row. A newer wish replaces the one waiting.

Parameters
ithe pane
needwhat is read
gofor NEED_PAGE, which page

Variable Documentation

◆ fs_s

fs_state_t fs_s

The screen's state; files_int.h names it s.

The screen's state, defined in files_screen.c.

The screen's state; files_int.h names it s.

◆ s_screen

const ui_screen_t s_screen
static
Initial value:
= {
.title = "FILES",
.reset = reset,
.enter = enter,
.leave = leave,
.tick = tick,
.event = fs_event,
.cancel = fs_cancel_press,
.render = fs_render,
.back = back,
}
void fs_render(gfx_canvas_t *c, int buffer_index)
FILES drawn: the panes and the footer, or a box over them, and the keyboard on top.
Definition files_draw.c:601
void fs_cancel_press(void)
Drop a press under way: the touch stream lost an event.
Definition files_events.c:96
void fs_event(const touch_event_t *e)
One touch event, in the screen's coordinates.
Definition files_events.c:344
static void enter(void)
On the way in: both panes read, from their first pages the first time and as they were left after tha...
Definition files_screen.c:1026
static void tick(float dt_s)
Time passed: the answer taken when it is in, the progress and the gate followed for the drawing.
Definition files_screen.c:1059
static bool back(void)
The home tag: a box or the keyboard closes, a job's box cancels a copy and stays; with the panes on t...
Definition files_screen.c:1096
static void leave(void)
On the way out: the keyboard and the boxes close; a job under way goes on, and its box shows again on...
Definition files_screen.c:1045
static void reset(void)
The screen as a start leaves it: the card's root on the left, USER LOG FOLDER on the right,...
Definition files_screen.c:1006

The screen's table for the router.