summaryrefslogtreecommitdiff
path: root/src/fe-common/core
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-06-12 22:57:53 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-06-12 22:57:53 +0000
commit18f3c74d68e79f5962000770fca9e663bf1b1c23 (patch)
treef16183cc068553da6080a481a5c83c14c97b7bd5 /src/fe-common/core
parent919abb2c6f8339e160a59b8ddcacfd403772379d (diff)
downloadirssi-18f3c74d68e79f5962000770fca9e663bf1b1c23.zip
CTCP msgs/replies stops the "event privmsg" or "event notice" signals now
so you don't have to check for them anymore (unless you use signal_add_first()..). /WINDOW MOVE command had some bugs. CTCP reply to some channel didn't display the channel name. Several code cleanups. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@327 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core')
-rw-r--r--src/fe-common/core/window-commands.c18
-rw-r--r--src/fe-common/core/window-items.c16
-rw-r--r--src/fe-common/core/window-items.h4
-rw-r--r--src/fe-common/core/windows.c8
-rw-r--r--src/fe-common/core/windows.h4
5 files changed, 35 insertions, 15 deletions
diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c
index d6207d0e..21ef23f4 100644
--- a/src/fe-common/core/window-commands.c
+++ b/src/fe-common/core/window-commands.c
@@ -125,7 +125,7 @@ static void cmd_window_next(void)
{
int num;
- num = window_refnum_next(active_win->refnum);
+ num = window_refnum_next(active_win->refnum, TRUE);
if (num < 1) num = windows_refnum_last();
window_set_active(window_find_refnum(num));
@@ -135,8 +135,8 @@ static void cmd_window_prev(void)
{
int num;
- num = window_refnum_prev(active_win->refnum);
- if (num < 1) num = window_refnum_next(0);
+ num = window_refnum_prev(active_win->refnum, TRUE);
+ if (num < 1) num = window_refnum_next(0, TRUE);
window_set_active(window_find_refnum(num));
}
@@ -239,9 +239,9 @@ static void cmd_window_move_left(void)
{
int refnum;
- refnum = window_refnum_prev(active_win->refnum);
+ refnum = window_refnum_prev(active_win->refnum, TRUE);
if (refnum != -1) {
- window_set_refnum(active_win, active_win->refnum-1);
+ window_set_refnum(active_win, refnum);
return;
}
@@ -252,9 +252,9 @@ static void cmd_window_move_right(void)
{
int refnum;
- refnum = window_refnum_next(active_win->refnum);
+ refnum = window_refnum_next(active_win->refnum, TRUE);
if (refnum != -1) {
- window_set_refnum(active_win, active_win->refnum+1);
+ window_set_refnum(active_win, refnum);
return;
}
@@ -273,7 +273,7 @@ static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *i
new_refnum = atoi(data);
if (new_refnum > active_win->refnum) {
for (;;) {
- refnum = window_refnum_next(active_win->refnum);
+ refnum = window_refnum_next(active_win->refnum, FALSE);
if (refnum == -1 || refnum > new_refnum)
break;
@@ -281,7 +281,7 @@ static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *i
}
} else {
for (;;) {
- refnum = window_refnum_prev(active_win->refnum);
+ refnum = window_refnum_prev(active_win->refnum, FALSE);
if (refnum == -1 || refnum < new_refnum)
break;
diff --git a/src/fe-common/core/window-items.c b/src/fe-common/core/window-items.c
index 54020ed3..790b7207 100644
--- a/src/fe-common/core/window-items.c
+++ b/src/fe-common/core/window-items.c
@@ -112,6 +112,22 @@ void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item)
}
}
+/* Return TRUE if `item' is the active window item in the window.
+ `item' can be NULL. */
+int window_item_is_active(WI_ITEM_REC *item)
+{
+ WINDOW_REC *window;
+
+ if (item == NULL)
+ return FALSE;
+
+ window = window_item_window(item);
+ if (window == NULL)
+ return FALSE;
+
+ return window->active == item;
+}
+
void window_item_prev(WINDOW_REC *window)
{
WI_ITEM_REC *last;
diff --git a/src/fe-common/core/window-items.h b/src/fe-common/core/window-items.h
index 34d61c2e..8e22c449 100644
--- a/src/fe-common/core/window-items.h
+++ b/src/fe-common/core/window-items.h
@@ -13,6 +13,10 @@ WINDOW_REC *window_item_window(WI_ITEM_REC *item);
void window_item_change_server(WI_ITEM_REC *item, void *server);
void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item);
+/* Return TRUE if `item' is the active window item in the window.
+ `item' can be NULL. */
+int window_item_is_active(WI_ITEM_REC *item);
+
void window_item_prev(WINDOW_REC *window);
void window_item_next(WINDOW_REC *window);
diff --git a/src/fe-common/core/windows.c b/src/fe-common/core/windows.c
index 85b617ef..8040078d 100644
--- a/src/fe-common/core/windows.c
+++ b/src/fe-common/core/windows.c
@@ -306,7 +306,7 @@ WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name)
return MODULE_DATA(item);
}
-int window_refnum_prev(int refnum)
+int window_refnum_prev(int refnum, int wrap)
{
GSList *tmp;
int prev, max;
@@ -317,14 +317,14 @@ int window_refnum_prev(int refnum)
if (rec->refnum < refnum && (prev == -1 || rec->refnum > prev))
prev = rec->refnum;
- if (max == -1 || rec->refnum > max)
+ if (wrap && (max == -1 || rec->refnum > max))
max = rec->refnum;
}
return prev != -1 ? prev : max;
}
-int window_refnum_next(int refnum)
+int window_refnum_next(int refnum, int wrap)
{
GSList *tmp;
int min, next;
@@ -335,7 +335,7 @@ int window_refnum_next(int refnum)
if (rec->refnum > refnum && (next == -1 || rec->refnum < next))
next = rec->refnum;
- if (min == -1 || rec->refnum < min)
+ if (wrap && (min == -1 || rec->refnum < min))
min = rec->refnum;
}
diff --git a/src/fe-common/core/windows.h b/src/fe-common/core/windows.h
index 98ef9425..69f292e4 100644
--- a/src/fe-common/core/windows.h
+++ b/src/fe-common/core/windows.h
@@ -69,8 +69,8 @@ WINDOW_REC *window_find_refnum(int refnum);
WINDOW_REC *window_find_name(const char *name);
WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name);
-int window_refnum_prev(int refnum);
-int window_refnum_next(int refnum);
+int window_refnum_prev(int refnum, int wrap);
+int window_refnum_next(int refnum, int wrap);
int windows_refnum_last(void);
void windows_init(void);