~strahinja/poe

ref: v1.01 poe/util.h -rw-r--r-- 1.5 KiB
7e7b946cСтрахиња Радић Fix: properly update first shown column when C-R/C-T in lines longer than edit box width 1 year, 4 months 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
#include <bits/stdint-uintn.h>
#include <sys/types.h>
#define ABS(a) ((a < 0) ? (-a) : (a))
#define LEN(x)	(sizeof(x) / sizeof(x[0]))
#define MAX(a,b) ((a > b) ? a : b)
#define MIN(a,b) ((a < b) ? a : b)

enum {
	ERR_UNKNOWN_KEY,
	ERR_EXIT_KEY,
	ERR_DLG_OPEN,
	ERR_DLG_OPEN_QUIT,
	ERR_EMPTY_FILE,
	ERR_CANT_ALLOC,
	ERR_CANT_SAVE,
	ERR_CANT_MOVE,
	ERR_ILLEGAL_ON_FIRST
};

#define MAXBUFLINE  4096
#define MAXDATEBUF  80
#define MAXFLAGSBUF (4+1)
#define MAXMSG      1024
#define MAXPATH     1024

size_t u8_string_to_unicode(uint32_t* us, const char* s, const size_t max);
size_t unicode_string_to_u8(char* s, const uint32_t* us, const size_t max);
size_t u32_encode_tabs(uint32_t* s, size_t max);
size_t u32_decode_tabs(uint32_t* s, size_t max);
size_t u32_strlen(const uint32_t* s);
uint32_t* u32_strstr(uint32_t* haystack, const uint32_t* needle);
size_t u32_strncpy(uint32_t* to, const uint32_t* from, size_t max);
size_t u32_strncat(uint32_t* to, const uint32_t* from, size_t max);
size_t u32_u8_strncpy(uint32_t* to, const char* from, size_t max);
size_t u8_u32_strncpy(char* to, const uint32_t* from, size_t max);
size_t u8_line_length(const char* s);
size_t u32_line_length(const uint32_t* s);
size_t u8_lines_in_string(const char* s, size_t* actual_lines);
size_t u32_lines_in_string(const uint32_t* s, size_t* actual_lines);
int starts_with(const char* s, const char* with);
int u32_starts_with(const uint32_t* s, const uint32_t* with);
const char* u8_basename(const char* path);
void poe_log(const char* msg, ...);