~ruther/CTU-FEE-B0B35APO-Semestral-project

ref: 70c513e16d3b45f21cfaae7537a1b3e19ced5a0f CTU-FEE-B0B35APO-Semestral-project/text-viewer/include/text_viewer.h -rw-r--r-- 1.4 KiB
70c513e1 — František Boháček feat: add correct error messages for text viewer and image viewer 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef __TEXT_VIEWER_H__
#define __TEXT_VIEWER_H__

#include "gui.h"
#include "gui_component_text_view.h"
#include "mzapo_pheripherals.h"

typedef enum {
  FILER_SUCCESS,
  FILER_NOT_FOUND,
  FILER_NO_PERMISSIONS,
  FILER_FILE_CANT_OPEN,
  FILER_CANNOT_READ,
  FILER_UNKNOWN,
} file_error_t;

typedef struct {
  gui_t gui;
  char *path;

  mzapo_pheripherals_t pheripherals;
  multiline_text_t *multiline_text;
  logger_t *logger;

  bool running;

  font_t font;
} text_viewer_t;

/**
 * @brief Create text viewer struct
 *
 * @param path path to file to open
 * @param pheripherals initialized pheripherals of mzapo
 * @param logger
 * @param font to display text with
 * @return text_viewer_t
 */
text_viewer_t text_viewer_create(char *path, mzapo_pheripherals_t pheripherals,
                                 logger_t *logger, font_t font);

void file_error_log(logger_t *logger, file_error_t error);

/**
 * @brief Cleans up text viewer data
 *
 * @param text_viewer Text viewer to clean up
 */
void text_viewer_destroy(text_viewer_t *text_viewer);

/**
 * @brief Load text file and parse it into memory
 *
 * @param text_viewer
 * @return file_error_t
 */
file_error_t text_viewer_load_file(text_viewer_t *text_viewer);

/**
 * @brief Start application - GUI render loop with input handling
 *
 * @param text_viewer
 */
void text_viewer_start_loop(text_viewer_t *text_viewer);

#endif // __TEXT_VIEWER_H__
Do not follow this link