home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Removed if-redundancy in get_drawfunc_by_char().
[plomrogue]
/
src
/
wincontrol.c
diff --git
a/src/wincontrol.c
b/src/wincontrol.c
index 41ba94525a24f1de3c05635a89ba7cd79ae84fae..7830636543232ba047a0c5f24fbbd4036a3642fa 100644
(file)
--- a/
src/wincontrol.c
+++ b/
src/wincontrol.c
@@
-10,7
+10,7
@@
* structs Win, WinMeta
*/
#include "yx_uint16.h" /* for yx_uint16 struct */
* structs Win, WinMeta
*/
#include "yx_uint16.h" /* for yx_uint16 struct */
-#include "main.h" /* for
Wins struct
*/
+#include "main.h" /* for
world global
*/
#include "readwrite.h" /* for get_linemax(), try_fopen(), try_fclose(),
* try_fgets(), try_fclose_unlink_rename(), try_fwrite()
*/
#include "readwrite.h" /* for get_linemax(), try_fopen(), try_fclose(),
* try_fgets(), try_fclose_unlink_rename(), try_fwrite()
*/
@@
-33,8
+33,6
@@
/* Return string "prefix" + "id"; malloc()'s string, remember to call free()! */
static char * string_prefixed_id(char * prefix, char id);
/* Return string "prefix" + "id"; malloc()'s string, remember to call free()! */
static char * string_prefixed_id(char * prefix, char id);
-
-
/* Create Winconf, init ->view/height_type/width_type to 0, ->id to "id". */
static void create_winconf(char id, struct WinConf * wcp);
/* Create Winconf, init ->view/height_type/width_type to 0, ->id to "id". */
static void create_winconf(char id, struct WinConf * wcp);
@@
-50,15
+48,11
@@
static void save_win_config(char id);
/* Free data pointed to inside WinConf struct. */
static void free_winconf_data(char id);
/* Free data pointed to inside WinConf struct. */
static void free_winconf_data(char id);
-
-
/* Write geometry of a window to its WinConf, as positive or negative values
* (dependent on state ofWinConf->height_type / WinConf->width_type).
*/
static void set_winconf_geometry(char id);
/* Write geometry of a window to its WinConf, as positive or negative values
* (dependent on state ofWinConf->height_type / WinConf->width_type).
*/
static void set_winconf_geometry(char id);
-
-
/* Get WinConf by "id"; get id of WinConf mothering "win". */
static struct WinConf * get_winconf_by_id(char id);
/* Get WinConf by "id"; get id of WinConf mothering "win". */
static struct WinConf * get_winconf_by_id(char id);
@@
-157,17
+151,11
@@
static void init_winconf_from_file(char id)
static void init_win_from_winconf(char id)
{
static void init_win_from_winconf(char id)
{
- char * tmp = "Trouble in init_win_from_file() with init_win() (win id: _).";
- char * err = try_malloc(strlen(tmp) + 1, "init_win_from_file()");
- memcpy(err, tmp, strlen(tmp) + 1);
- err[strlen(tmp) - 3] = id;
+ char * err = "get_drawfunc_by_char() returns NULL to init_win_from_file().";
struct WinConf * winconf = get_winconf_by_id(id);
void * f = get_drawfunc_by_char(winconf->draw);
exit_err(NULL == f, err);
struct WinConf * winconf = get_winconf_by_id(id);
void * f = get_drawfunc_by_char(winconf->draw);
exit_err(NULL == f, err);
- uint8_t test = init_win(world.wmeta, &winconf->win, winconf->title,
- winconf->height, winconf->width, f);
- exit_err(test, err);
- free(err);
+ init_win(&winconf->win, winconf->title, winconf->height, winconf->width, f);
}
}
@@
-278,7
+266,7
@@
static void * get_drawfunc_by_char(char c)
{
return draw_win_inventory;
}
{
return draw_win_inventory;
}
-
if
('i' == c)
+
else if
('i' == c)
{
return draw_win_info;
}
{
return draw_win_info;
}
@@
-449,12
+437,11
@@
extern void sorted_wintoggle_and_activate()
{
continue;
}
{
continue;
}
- struct Win * win = get_win_by_id(win_order[i]);
- toggle_window(world.wmeta, win);
+ toggle_window(win_order[i]);
if (a == (uint8_t) win_order[i])
{
if (a == (uint8_t) win_order[i])
{
- world.wmeta->active =
win
;
+ world.wmeta->active =
get_win_by_id(win_order[i])
;
}
}
}
}
}
}
@@
-498,23
+485,25
@@
extern void save_win_configs()
-extern
uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win
)
+extern
void toggle_window(char id
)
{
{
- if (0 == win->prev && win_meta->chain_start != win) /* Win outside chain. */
- {
- return append_win(win_meta, win);
+ struct Win * win = get_win_by_id(id);
+ if (0 == win->prev && world.wmeta->chain_start != win) /* Win struct is */
+ { /* outside chain. */
+ append_win(win);
}
else
{
}
else
{
-
return suspend_win(win_meta,
win);
+
suspend_win(
win);
}
}
}
}
-extern void toggle_winconfig(
struct Win * win
)
+extern void toggle_winconfig()
{
{
- struct WinConf * wcp = get_winconf_by_win(win);
+ struct Win * win = world.wmeta->active;
+ struct WinConf * wcp = get_winconf_by_win(win);
if (0 == wcp->view)
{
win->draw = draw_winconf_geometry;
if (0 == wcp->view)
{
win->draw = draw_winconf_geometry;
@@
-539,8
+528,9
@@
extern void toggle_winconfig(struct Win * win)
-extern void toggle_win_height_type(
struct Win * win
)
+extern void toggle_win_height_type()
{
{
+ struct Win * win = world.wmeta->active;
struct WinConf * wcp = get_winconf_by_win(win);
if (0 == wcp->height_type)
{
struct WinConf * wcp = get_winconf_by_win(win);
if (0 == wcp->height_type)
{
@@
-555,8
+545,9
@@
extern void toggle_win_height_type(struct Win * win)
-extern void toggle_win_width_type(
struct Win * win
)
+extern void toggle_win_width_type()
{
{
+ struct Win * win = world.wmeta->active;
struct WinConf * wcp = get_winconf_by_win(win);
if (0 == wcp->width_type && win->framesize.x <= world.wmeta->padsize.x)
{
struct WinConf * wcp = get_winconf_by_win(win);
if (0 == wcp->width_type && win->framesize.x <= world.wmeta->padsize.x)
{
@@
-571,21
+562,21
@@
extern void toggle_win_width_type(struct Win * win)
-extern void scroll_pad(
struct WinMeta * win_meta,
char dir)
+extern void scroll_pad(char dir)
{
if ('+' == dir)
{
{
if ('+' == dir)
{
- reset_pad_offset(w
in_meta, win_
meta->pad_offset + 1);
+ reset_pad_offset(w
orld.w
meta->pad_offset + 1);
}
else if ('-' == dir)
{
}
else if ('-' == dir)
{
- reset_pad_offset(w
in_meta, win_
meta->pad_offset - 1);
+ reset_pad_offset(w
orld.w
meta->pad_offset - 1);
}
}
}
}
-extern
uint8_t
growshrink_active_window(char change)
+extern
void
growshrink_active_window(char change)
{
if (0 != world.wmeta->active)
{
{
if (0 != world.wmeta->active)
{
@@
-606,7
+597,7
@@
extern uint8_t growshrink_active_window(char change)
{
size.x++;
}
{
size.x++;
}
-
uint8_t x = resize_active_win(world.wmeta,
size);
+
resize_active_win(
size);
struct WinConf * wcp = get_winconf_by_win(world.wmeta->active);
if ( 1 == wcp->width_type
&& world.wmeta->active->framesize.x > world.wmeta->padsize.x)
struct WinConf * wcp = get_winconf_by_win(world.wmeta->active);
if ( 1 == wcp->width_type
&& world.wmeta->active->framesize.x > world.wmeta->padsize.x)
@@
-614,7
+605,5
@@
extern uint8_t growshrink_active_window(char change)
wcp->width_type = 0;
}
set_winconf_geometry(wcp->id);
wcp->width_type = 0;
}
set_winconf_geometry(wcp->id);
- return x;
}
}
- return 0;
}
}