0 /* See LICENSE file for copyright and license details. */

1 #ifndef _GEMINI_H_

2 #define _GEMINI_H_

3

4 #include <unistd.h>

5 #include <stddef.h>

6 #ifndef _SCHEME_H

7 #include "memcheck.h"

8 #endif

9 #include "scheme.h"

10

11 #define GMI 9

12 #define P_FILE 7

13 #define MAX_URL 1024

14 #define MAX_META 1024

15

16 struct gmi_link {

17 char url[MAX_URL];

18 struct gmi_link* prev;

19 struct gmi_link* next;

20 int scroll;

21 char* data;

22 };

23

24 struct gmi_obj {

25 char id[64];

26 char* value;

27 int start;

28 int end;

29 };

30

31 struct gmi_page {

32 char** links;

33 int links_count;

34 char* data;

35 int data_len;

36 int code;

37 int lines;

38 char meta[MAX_META];

39 struct img {

40 int tried;

41 unsigned char* data;

42 int w;

43 int h;

44 int channels;

45 } img;

46 struct gmi_obj* objs;

47 int objs_count;

48 int script_start;

49 int script_exec;

50 };

51

52 struct gmi_tab {

53 struct gmi_link* history;

54 struct gmi_page page;

55 int scroll;

56 int selected;

57 char selected_url[MAX_URL];

58 char url[MAX_URL];

59 char error[256];

60 char info[256];

61 scheme* ctx;

62 };

63

64 struct gmi_client {

65 struct gmi_tab* tabs;

66 int tabs_count;

67 struct input {

68 char label[MAX_URL];

69 char field[MAX_URL];

70 int error;

71 int info;

72 int cursor;

73 int mode;

74 } input;

75 struct vim {

76 char counter[6];

77 int g;

78 } vim;

79 char** bookmarks;

80 int tab;

81 #ifndef DISABLE_XDG

82 int xdg;

83 #endif

84 int c256;

85 int shutdown;

86 int refresh;

87 };

88

89 extern struct gmi_client client;

90 int gmi_init();

91 int gmi_goto(int id);

92 int gmi_goto_new(int id);

93 int gmi_request(const char* url);

94 void gmi_load(struct gmi_page* page);

95 int gmi_render(struct gmi_tab* tab);

96 int gmi_parseurl(const char* url, char* host, int host_len, char* urlbuf, int url_len, unsigned short* port);

97 void gmi_cleanforward(struct gmi_tab* tab);

98 int gmi_nextlink(char* url, char* link);

99 void gmi_newtab();

100 void gmi_newtab_url(char* url);

101 int gmi_loadfile(char* path);

102 void gmi_addbookmark(char* url, char* title);

103 int gmi_removebookmark(int index);

104 void gmi_gohome(struct gmi_tab* tab);

105 void gmi_freetab(struct gmi_tab* tab);

106 void gmi_free();

107

108 #include "img.h"

109 #ifdef TERMINAL_IMG_VIEWER

110 #undef TB_WHITE

111 #define TB_WHITE 15

112 #undef TB_BLACK

113 #define TB_BLACK 16

114 #undef TB_BLUE

115 #define TB_BLUE 4

116 #undef TB_RED

117 #define TB_RED 9

118 #undef TB_GREEN

119 #define TB_GREEN 2

120 #undef TB_CYAN

121 #define TB_CYAN 14

122 #undef TB_MAGENTA

123 #define TB_MAGENTA 13

124 #undef TB_ITALIC

125 #define TB_ITALIC 0

126 #endif

127

128 #endif

129