mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
wip: pgo without Wayland
* Split up source files into several static libraries: misc + vtlib * Add a new executable, pgo, that links to vtlib * pgo is kind of like a mock test: - provides stub implementations of functions not present in vtlib - sets up a dummy terminal instance - calls vt_from_slave() with static (pre-generated) content
This commit is contained in:
parent
861f3a4e6d
commit
4577bb2bb3
3 changed files with 271 additions and 13 deletions
50
meson.build
50
meson.build
|
|
@ -100,24 +100,52 @@ version = custom_target(
|
||||||
output: 'version.h',
|
output: 'version.h',
|
||||||
command: [generate_version_sh, meson.project_version(), '@SOURCE_DIR@', '@OUTPUT@'])
|
command: [generate_version_sh, meson.project_version(), '@SOURCE_DIR@', '@OUTPUT@'])
|
||||||
|
|
||||||
|
misc = static_library(
|
||||||
|
'misc',
|
||||||
|
'hsl.c', 'hsl.h',
|
||||||
|
'macros.h',
|
||||||
|
'misc.c', 'misc.h',
|
||||||
|
'uri.c', 'uri.h',
|
||||||
|
'xmalloc.c', 'xmalloc.h',
|
||||||
|
)
|
||||||
|
|
||||||
|
vtlib = static_library(
|
||||||
|
'vtlib',
|
||||||
|
'base64.c', 'base64.h',
|
||||||
|
'csi.c', 'csi.h',
|
||||||
|
'dcs.c', 'dcs.h',
|
||||||
|
'osc.c', 'osc.h',
|
||||||
|
'sixel.c', 'sixel.h',
|
||||||
|
'vt.c', 'vt.h',
|
||||||
|
dependencies: [pixman],
|
||||||
|
link_with: misc,
|
||||||
|
)
|
||||||
|
|
||||||
|
pgolib = static_library(
|
||||||
|
'pgolib',
|
||||||
|
'grid.c', 'grid.h',
|
||||||
|
'terminal.c', 'terminal.h',
|
||||||
|
dependencies: [pixman, fcft],
|
||||||
|
link_with: vtlib,
|
||||||
|
)
|
||||||
|
|
||||||
|
executable(
|
||||||
|
'pgo',
|
||||||
|
'pgo.c',
|
||||||
|
dependencies: [pixman, fcft],
|
||||||
|
link_with: pgolib,
|
||||||
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
'foot',
|
'foot',
|
||||||
'async.c', 'async.h',
|
'async.c', 'async.h',
|
||||||
'base64.c', 'base64.h',
|
|
||||||
'config.c', 'config.h',
|
'config.c', 'config.h',
|
||||||
'commands.c', 'commands.h',
|
'commands.c', 'commands.h',
|
||||||
'csi.c', 'csi.h',
|
|
||||||
'dcs.c', 'dcs.h',
|
|
||||||
'extract.c', 'extract.h',
|
'extract.c', 'extract.h',
|
||||||
'fdm.c', 'fdm.h',
|
'fdm.c', 'fdm.h',
|
||||||
'grid.c', 'grid.h',
|
|
||||||
'hsl.c', 'hsl.h',
|
|
||||||
'input.c', 'input.h',
|
'input.c', 'input.h',
|
||||||
'log.c', 'log.h',
|
'log.c', 'log.h',
|
||||||
'macros.h',
|
|
||||||
'main.c',
|
'main.c',
|
||||||
'misc.c', 'misc.h',
|
|
||||||
'osc.c', 'osc.h',
|
|
||||||
'quirks.c', 'quirks.h',
|
'quirks.c', 'quirks.h',
|
||||||
'reaper.c', 'reaper.h',
|
'reaper.c', 'reaper.h',
|
||||||
'render.c', 'render.h',
|
'render.c', 'render.h',
|
||||||
|
|
@ -125,19 +153,15 @@ executable(
|
||||||
'selection.c', 'selection.h',
|
'selection.c', 'selection.h',
|
||||||
'server.c', 'server.h', 'client-protocol.h',
|
'server.c', 'server.h', 'client-protocol.h',
|
||||||
'shm.c', 'shm.h',
|
'shm.c', 'shm.h',
|
||||||
'sixel.c', 'sixel.h',
|
|
||||||
'slave.c', 'slave.h',
|
'slave.c', 'slave.h',
|
||||||
'spawn.c', 'spawn.h',
|
'spawn.c', 'spawn.h',
|
||||||
'terminal.c', 'terminal.h',
|
|
||||||
'tokenize.c', 'tokenize.h',
|
'tokenize.c', 'tokenize.h',
|
||||||
'uri.c', 'uri.h',
|
|
||||||
'user-notification.h',
|
'user-notification.h',
|
||||||
'vt.c', 'vt.h',
|
|
||||||
'wayland.c', 'wayland.h',
|
'wayland.c', 'wayland.h',
|
||||||
'xmalloc.c', 'xmalloc.h',
|
|
||||||
wl_proto_src + wl_proto_headers, version,
|
wl_proto_src + wl_proto_headers, version,
|
||||||
dependencies: [math, threads, pixman, wayland_client, wayland_cursor, xkb, fontconfig,
|
dependencies: [math, threads, pixman, wayland_client, wayland_cursor, xkb, fontconfig,
|
||||||
tllist, fcft],
|
tllist, fcft],
|
||||||
|
link_with: pgolib,
|
||||||
install: true)
|
install: true)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
|
|
|
||||||
1
pgo-input-80x24.raw
Normal file
1
pgo-input-80x24.raw
Normal file
File diff suppressed because one or more lines are too long
233
pgo.c
Normal file
233
pgo.c
Normal file
|
|
@ -0,0 +1,233 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include "async.h"
|
||||||
|
#include "user-notification.h"
|
||||||
|
#include "vt.h"
|
||||||
|
|
||||||
|
void wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...) {}
|
||||||
|
|
||||||
|
enum async_write_status
|
||||||
|
async_write(int fd, const void *data, size_t len, size_t *idx)
|
||||||
|
{
|
||||||
|
return ASYNC_WRITE_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
selection_enabled(const struct terminal *term, struct seat *seat)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void selection_cancel(struct terminal *term) {}
|
||||||
|
void selection_clipboard_unset(struct seat *seat) {}
|
||||||
|
void selection_primary_unset(struct seat *seat) {}
|
||||||
|
|
||||||
|
bool
|
||||||
|
text_to_clipboard(
|
||||||
|
struct seat *seat, struct terminal *term, char *text, uint32_t serial)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
text_to_primary(
|
||||||
|
struct seat *seat, struct terminal *term, char *text, uint32_t serial)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
selection_clipboard_has_data(const struct seat *seat)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
selection_primary_has_data(const struct seat *seat)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
text_from_clipboard(
|
||||||
|
struct seat *seat, struct terminal *term,
|
||||||
|
void (*cb)(char *data, size_t size, void *user),
|
||||||
|
void (*done)(void *user), void *user)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
text_from_primary(
|
||||||
|
struct seat *seat, struct terminal *term,
|
||||||
|
void (*cb)(char *data, size_t size, void *user),
|
||||||
|
void (*dont)(void *user), void *user)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
selection_on_rows(const struct terminal *term, int start, int end)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void selection_view_up(struct terminal *term, int new_view) {}
|
||||||
|
void selection_view_down(struct terminal *term, int new_view) {}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fdm_del(struct fdm *fdm, int fd)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fdm_event_add(struct fdm *fdm, int fd, int events)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fdm_event_del(struct fdm *fdm, int fd, int events)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
render_resize_force(struct terminal *term, int width, int height)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_refresh(struct terminal *term) {}
|
||||||
|
void render_refresh_csd(struct terminal *term) {}
|
||||||
|
void render_refresh_title(struct terminal *term) {}
|
||||||
|
|
||||||
|
bool
|
||||||
|
render_xcursor_set(struct seat *seat, struct terminal *term, const char *xcursor)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wl_window *
|
||||||
|
wayl_win_init(struct terminal *term)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wayl_win_destroy(struct wl_window *win) {}
|
||||||
|
|
||||||
|
bool
|
||||||
|
spawn(struct reaper *reaper, const char *cwd, char *const argv[],
|
||||||
|
int stdin_fd, int stdout_fd, int stderr_fd)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
slave_spawn(
|
||||||
|
int ptmx, int argc, const char *cwd, char *const *argv, const char *term_env,
|
||||||
|
const char *conf_shell, bool login_shell,
|
||||||
|
const user_notifications_t *notifications)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
render_worker_thread(void *_ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct extraction_context *
|
||||||
|
extract_begin(enum selection_kind kind)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
extract_one(
|
||||||
|
const struct terminal *term, const struct row *row, const struct cell *cell,
|
||||||
|
int col, void *context)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
extract_finish(struct extraction_context *context, char **text, size_t *len)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, const char *const *argv)
|
||||||
|
{
|
||||||
|
const int row_count = 24;
|
||||||
|
const int col_count = 80;
|
||||||
|
const int grid_row_count = 1024;
|
||||||
|
|
||||||
|
struct row **rows = calloc(grid_row_count, sizeof(rows[0]));
|
||||||
|
for (int i = 0; i < grid_row_count; i++) {
|
||||||
|
rows[i] = calloc(1, sizeof(*rows[i]));
|
||||||
|
rows[i]->cells = calloc(col_count, sizeof(rows[i]->cells[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct terminal term = {
|
||||||
|
.grid = &term.normal,
|
||||||
|
.normal = {
|
||||||
|
.num_rows = grid_row_count,
|
||||||
|
.num_cols = col_count,
|
||||||
|
.rows = rows,
|
||||||
|
.cur_row = rows[0],
|
||||||
|
},
|
||||||
|
.alt = {
|
||||||
|
.num_rows = grid_row_count,
|
||||||
|
.num_cols = col_count,
|
||||||
|
.rows = rows,
|
||||||
|
.cur_row = rows[0],
|
||||||
|
},
|
||||||
|
.scale = 1,
|
||||||
|
.width = col_count * 8,
|
||||||
|
.height = row_count * 15,
|
||||||
|
.cols = col_count,
|
||||||
|
.rows = row_count,
|
||||||
|
.cell_width = 8,
|
||||||
|
.cell_height = 15,
|
||||||
|
.scroll_region = {
|
||||||
|
.start = 0,
|
||||||
|
.end = row_count,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
struct stat st;
|
||||||
|
if (stat(argv[1], &st) < 0)
|
||||||
|
return 1;
|
||||||
|
uint8_t *data = malloc(st.st_size);
|
||||||
|
int fd = open(argv[1], O_RDONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
return 1;
|
||||||
|
ssize_t amount = read(fd, data, st.st_size);
|
||||||
|
if (amount != st.st_size)
|
||||||
|
return 1;
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
vt_from_slave(&term, data, st.st_size);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
for (int i = 0; i < grid_row_count; i++) {
|
||||||
|
free(rows[i]->cells);
|
||||||
|
free(rows[i]);
|
||||||
|
}
|
||||||
|
free(rows);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue