Skip to content

Commit

Permalink
Fix DEBUG section
Browse files Browse the repository at this point in the history
  • Loading branch information
Titor8115 committed Oct 3, 2021
1 parent 57cce67 commit f7868d5
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 127 deletions.
3 changes: 1 addition & 2 deletions src/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ typedef enum {
CMD_RESIZE_EVENT,
CMD_MOUSE_TOGGLE,
CMD_MOUSE_EVENT,

CMD_COMFIRM = 100,
CMD_SELECT_HREF,
CMD_COMFIRM = 100,
CMD_MOVE_DOWN,
CMD_MOVE_UP,
CMD_MOVE_NPAGE,
Expand Down
40 changes: 19 additions & 21 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#include <string.h>
#include <unistd.h>

static struct mdn_cfg default_cfg =
{
.use_mouse = CONFIG_TRUE,
.indent = 7,
.control_scheme = "less"
static struct mdn_cfg rc_rule =
{
.use_mouse = CONFIG_TRUE,
.indent = 7,
.control_scheme = "less",
};

void sd_info(char *output)
Expand Down Expand Up @@ -67,42 +67,42 @@ get_user_rc(config_t *user, struct mdn_cfg *config, FILE *fp)
if (fp != NULL) {
// fputs("# If you want Terminal Emulator handle mouse event\n# turn off \"use_mouse\"\n", fp);
// setting = config_setting_add(&update.root, "use_mouse", CONFIG_TYPE_BOOL);
// config_setting_set_bool(setting, default_cfg.use_mouse);
// config_setting_set_bool(setting, rc_rule.use_mouse);
// config_write(&update, fp);
// config_setting_remove(&update.root, "use_mouse");
fprintf(fp,
"# If you want Terminal Emulator handle mouse event\n"
"# turn off \"use_mouse\"\n"
"use_mouse = %s;\n\n",
(default_cfg.use_mouse ? "true" : "false"));
fprintf(fp,
"# If you want Terminal Emulator handle mouse event\n"
"# turn off \"use_mouse\"\n"
"use_mouse = %s;\n\n",
(rc_rule.use_mouse ? "true" : "false"));
}
}
else
default_cfg.use_mouse = config_setting_get_bool(setting);
rc_rule.use_mouse = config_setting_get_bool(setting);

setting = config_lookup(user, "indent");
if (!config_lookup_int(user, "indent", &(default_cfg.indent))) {
if (!config_lookup_int(user, "indent", &(rc_rule.indent))) {
if (fp != NULL) {
fprintf(fp,
"# Indent controls where manual's content start for each line\n"
"indent = %d;\n\n",
default_cfg.indent);
rc_rule.indent);
}
}
else
default_cfg.indent = config_setting_get_int(setting);
rc_rule.indent = config_setting_get_int(setting);

setting = config_lookup(user, "control_scheme");
if (!setting) {
if (fp != NULL) {
fprintf(fp,
"# Supported Keybinding: \"mdn\", \"vim\", \"less\"\n"
"control_scheme = \"%s\";\n\n",
default_cfg.control_scheme);
rc_rule.control_scheme);
}
}
else {
default_cfg.control_scheme[0] = config_setting_get_string(setting)[0];
rc_rule.control_scheme[0] = config_setting_get_string(setting)[0];
}

return config;
Expand Down Expand Up @@ -133,13 +133,11 @@ configure()
}
else {
config_read(&cfg, fp_rc);
get_user_rc(&cfg, &default_cfg, fp_rc);
get_user_rc(&cfg, &rc_rule, fp_rc);
fclose(fp_rc);
}
// }

/* Clean up */
config_destroy(&cfg);
free(rc_path);
return &default_cfg;
return &rc_rule;
}
32 changes: 24 additions & 8 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#define MDN_CONFIG_H

#include <libconfig.h>

#include "buffer.h"
#include "st_curses.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -40,18 +42,32 @@ extern "C" {
#define SCHEME_MDN 0
#define SCHEME_LESS 1
#define SCHEME_VIM 2
#ifdef DEBUG
struct color_pair_t {
short fg;
short bg;
};

struct scheme {
int key;
int command;
struct buf *str_form;
struct color_t {
struct color_pair_t text;
struct color_pair_t header;
struct color_pair_t link;
struct color_pair_t code;
};

#endif


struct mdn_cfg {
struct scheme map[14];
char control_scheme[5];
int use_mouse;
int indent;
#ifdef DEBUG
struct color_pair_t pager;
struct color_t color;

#endif

char control_scheme[5];
int use_mouse;
int indent;
};

void sd_info(char *);
Expand Down
1 change: 1 addition & 0 deletions src/mandown.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "blender.h"
#include "buffer.h"
#include "config.h"
#include "markdown.h"
#include "view.h"

Expand Down
Loading

0 comments on commit f7868d5

Please sign in to comment.