home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reduced code complexity by stronger integrating windows library.
[plomrogue]
/
src
/
wincontrol.c
diff --git
a/src/wincontrol.c
b/src/wincontrol.c
index 41ba94525a24f1de3c05635a89ba7cd79ae84fae..7933d48ad5b16b705b2a774d08dfa49715e928ee 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()
*/
@@
-157,17
+157,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);
}
}
@@
-449,12
+443,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
+491,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
+534,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
+551,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
+568,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
+603,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
+611,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;
}
}