blob: 67a28ff9ec05b8aaba4d34a4d1beaa7f4f8b1260 (
plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#ifndef MAIN_METAG_H
#define MAIN_METAG_H
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700 // For strnlen()
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <ncurses.h>
#include <getopt.h>
#include <taglib/tag_c.h>
typedef struct tagInfo {
TagLib_File *file;
TagLib_Tag *tag;
const TagLib_AudioProperties *properties;
} tagInfo;
typedef struct itemC {
char* cstr;
int opt;
char* suffix;
char* prefix;
tagInfo info;
int selected;
int id;
} itemC;
typedef struct menuC {
itemC* list;
int nbElem;
int hl;
int firstElem;
int opt; // SCROLL | HL_HIDE | HL_HIDE | HL_BOLD | HL_CLIGN | HL_INV [ | BORDER ]
char* suffix;
char* prefix;
int x,y,w,h;
} menuC;
#define HIDDEN 1
void printStatus(void);
void resize(void);
void fail_exit(const char *msg);
// Checks errors for (most) ncurses functions. CHECK(fn, x, y, z) is a checked
// version of fn(x, y, z).
#define CHECK(fn, ...) \
do \
if (fn(__VA_ARGS__) == ERR) \
fail_exit(#fn"() failed"); \
while (false)
#define max(a, b) \
({ typeof(a) _a = a; \
typeof(b) _b = b; \
_a > _b ? _a : _b; })
#define VERSION_METAG "Alpha"
#define HELP_STRING_METAG "Utilisation : metag [OPTION]..." "\n"\
"Editeur de tag mp3" "\n"\
"Options :" "\n"\
"\t\t--help -h Affiche l'aide simple" "\n"\
"\t\t--version -v Affiche la version" "\n"\
"\t\t--dir -d Change le répertoire de travail " "\n"\
"\n" "\n"\
"Basic control :\n" "\n"\
" 'e%' - edit % where % can be :\n" "\n"\
" t for title | a for artist | b for album | g for genre" "\n"\
" y for year | y for comment | n for track number" "\n"\
"" "\n"\
" 'q' to exit" "\n"\
"" "\n"\
" 's' select by regex" "\n"\
"" "\n"\
" 'x' extract information from the title by regex" "\n"\
"" "\n"\
" ' ' toggle selection of the current item" "\n"\
"" "\n"\
" 'k' selection up" "\n"\
" 'j' selection down" "\n"\
""
#endif
|