home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improved and defined more precisely textfile_sizes().
[plomrogue]
/
src
/
keybindings.c
diff --git
a/src/keybindings.c
b/src/keybindings.c
index f33b559407fe419e8ab18e1bb292731cddf27416..8b01958c940d5079f4d5157b6034a92f918a056e 100644
(file)
--- a/
src/keybindings.c
+++ b/
src/keybindings.c
@@
-10,19
+10,21
@@
#include "windows.h" /* for draw_all_wins() and WinMeta struct */
#include "misc.h" /* for texfile_sizes() */
#include "main.h" /* for World struct */
#include "windows.h" /* for draw_all_wins() and WinMeta struct */
#include "misc.h" /* for texfile_sizes() */
#include "main.h" /* for World struct */
+#include "rexit.h" /* for err_exit() */
extern void init_keybindings(struct World * world)
{
extern void init_keybindings(struct World * world)
{
- FILE * file = fopen("keybindings", "r");
+ FILE * file = fopen("
config/
keybindings", "r");
uint16_t lines, linemax;
uint16_t lines, linemax;
- textfile_sizes(file, &linemax, &lines);
+ char * err = "textfile_sizes() in init_keybindings() returns error.";
+ exit_err(textfile_sizes(file, &linemax, &lines), world, err);
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
- char * command = malloc(linemax);
+ char * command = malloc(linemax
+ 1
);
uint16_t commcount = 0;
char * cmdptr;
uint16_t commcount = 0;
char * cmdptr;
- while (fgets(command, linemax, file))
+ while (fgets(command, linemax
+ 1
, file))
{
keybindings[commcount].key = atoi(command);
cmdptr = strchr(command, ' ') + 1;
{
keybindings[commcount].key = atoi(command);
cmdptr = strchr(command, ' ') + 1;
@@
-48,7
+50,7
@@
extern void save_keybindings(struct World * world)
struct KeysWinData * keyswindata = (struct KeysWinData *)
world->keyswindata;
struct KeyBinding * keybindings = world->keybindings;
struct KeysWinData * keyswindata = (struct KeysWinData *)
world->keyswindata;
struct KeyBinding * keybindings = world->keybindings;
- FILE * file = fopen("keybindings", "w");
+ FILE * file = fopen("
config/
keybindings", "w");
uint16_t linemax = 0;
uint16_t i;
for (i = 0; i <= keyswindata->max; i++)
uint16_t linemax = 0;
uint16_t i;
for (i = 0; i <= keyswindata->max; i++)
@@
-169,7
+171,8
@@
extern char * get_keyname(uint16_t keycode)
extern void keyswin_mod_key(struct World * world, struct WinMeta * win_meta)
{
world->keyswindata->edit = 1;
extern void keyswin_mod_key(struct World * world, struct WinMeta * win_meta)
{
world->keyswindata->edit = 1;
- draw_all_wins(win_meta);
+ exit_err(draw_all_wins(win_meta), world, "Trouble with draw_all_wins() in "
+ "keyswin_mod_key().");
int key = getch();
if (key < 1000)
{
int key = getch();
if (key < 1000)
{