summaryrefslogtreecommitdiff
path: root/libcons/cons-switch.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-09-09 22:04:25 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-09-09 22:04:25 +0000
commit80a243f5e1ce1a023cb45c6ecfa9ccc2b83312d7 (patch)
tree21f975420d18143021535ac9af55184c15fa5377 /libcons/cons-switch.c
parent18cfa8b70ce9a6a3572908115f98211f3fa9a367 (diff)
libcons/
2002-09-09 Marcus Brinkmann <marcus@gnu.org> * Makefile (SRCS): Add vcons-scrollback.c. * vcons-scrollback.c: New file. * cons.h (struct vcons): Add SCROLLING member. * file-changed.c: Include <assert.h>. (cons_S_file_changed): Be careful to take VCONS->scrolling into account when doing clipping and scrolling. * cons-switch.c: Roll back to earlier version with vcons -> vcons_entry adjustments. The user is now expected to hold a reference to the VCONS. * cons.h: Fix prototype, too. * vcons-open.c (cons_vcons_open): Initialize VCONS->lock, VCONS->input and VCONS->display. utils/ 2002-09-09 Marcus Brinkmann <marcus@gnu.org> * console-ncurses.c (console_switch): Keep a reference to the port instead refering to it by number.
Diffstat (limited to 'libcons/cons-switch.c')
-rw-r--r--libcons/cons-switch.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/libcons/cons-switch.c b/libcons/cons-switch.c
index d9aa64af..c39e83da 100644
--- a/libcons/cons-switch.c
+++ b/libcons/cons-switch.c
@@ -23,44 +23,47 @@
#include "cons.h"
-/* Open the virtual console ID or the ACTIVE_ID plus DELTA one in CONS
- and return it in R_VCONS, which will be locked. */
+/* Open the virtual console ID or the virtual console DELTA steps away
+ from VCONS in the linked list and return it in R_VCONS, which will
+ be locked. */
error_t
-cons_switch (cons_t cons, int active_id, int id, int delta, vcons_t *r_vcons)
+cons_switch (vcons_t vcons, int id, int delta, vcons_t *r_vcons)
{
error_t err = 0;
+ cons_t cons = vcons->cons;
vcons_list_t vcons_entry = NULL;
if (!id && !delta)
return 0;
mutex_lock (&cons->lock);
- vcons_entry = cons->vcons_list;
- while (vcons_entry && vcons_entry->id != (id ?: active_id))
- vcons_entry = vcons_entry->next;
-
- if (!id && vcons_entry)
+ if (id)
+ {
+ vcons_entry = cons->vcons_list;
+ while (vcons_entry && vcons_entry->id != id)
+ vcons_entry = vcons_entry->next;
+ }
+ else if (delta > 0)
+ {
+ vcons_entry = vcons->vcons_entry;
+ while (delta-- > 0)
+ {
+ vcons_entry = vcons_entry->next;
+ if (!vcons_entry)
+ vcons_entry = cons->vcons_list;
+ }
+ }
+ else
{
- if (delta > 0)
- {
- while (delta-- > 0)
- {
- vcons_entry = vcons_entry->next;
- if (!vcons_entry)
- vcons_entry = cons->vcons_list;
- }
- }
- else
- {
- assert (delta < 0);
- while (delta++ < 0)
- {
- vcons_entry = vcons_entry->prev;
- if (!vcons_entry)
- vcons_entry = cons->vcons_last;
- }
- }
+ assert (delta < 0);
+ while (delta++ < 0)
+ {
+ vcons_entry = vcons_entry->prev;
+ if (!vcons_entry)
+ vcons_entry = cons->vcons_last;
+ }
}
+
if (!vcons_entry)
{
mutex_unlock (&cons->lock);
@@ -78,6 +81,7 @@ cons_switch (cons_t cons, int active_id, int id, int delta, vcons_t *r_vcons)
if (!err)
vcons_entry->vcons = *r_vcons;
}
+
mutex_unlock (&cons->lock);
return err;
}