cnoor: show juz numbers
[cnoor.git] / cnoor.c
blobdef6cd25d892e1eef1b48ca95c2d1f7352bacbf6
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include "config.h"
4 #include "txtwin.h"
5 #include "quran.h"
6 #include "util.h"
8 static void ins_sura(struct txtwin *tw, struct quran *quran,
9 struct quran *trans, int sura)
11 char buf[16 * 1024];
12 int start = sura_start(sura);
13 int ayas = sura_ayas(sura);
14 int i;
15 for (i = 0; i < ayas; i++) {
16 int juz = juz_start(sura, i + 1);
17 if (juz) {
18 sprintf(buf, "%d", juz);
19 txtwin_append(tw, buf, "juz");
21 quran_aya(quran, buf, LENGTH(buf), start + i);
22 txtwin_append(tw, buf, "quran");
23 sprintf(buf, " %d ", i + 1);
24 txtwin_append(tw, buf, "num");
25 if (trans) {
26 quran_aya(trans, buf, LENGTH(buf), start + i);
27 txtwin_append(tw, "\n", NULL);
28 txtwin_append(tw, buf, "trans");
30 txtwin_append(tw, "\n\n", NULL);
34 static void set_tags(struct txtwin *tw)
36 int i;
37 for (i = 0; i < LENGTH(styles); i++)
38 txtwin_tag(tw, styles[i].name, styles[i].fg,
39 styles[i].bg, styles[i].font);
42 int main(int argc, char **argv)
44 struct txtwin *tw;
45 struct quran *quran;
46 struct quran *trans = NULL;
47 txtwin_gtk_init(argc, argv);
48 tw = txtwin_alloc();
49 quran = quran_alloc(QURAN_PATH);
50 if (TRANS_PATH)
51 trans = quran_alloc(TRANS_PATH);
52 set_tags(tw);
53 if (argc > 1)
54 ins_sura(tw, quran, trans, atoi(argv[1]));
56 txtwin_loop(tw);
57 txtwin_free(tw);
58 quran_free(quran);
59 return 0;