2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
4 * Copyright (c) 2008, 2009
5 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
6 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
7 * Micah Cowan (micah@cowan.name)
8 * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
9 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
10 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
11 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
12 * Copyright (c) 1987 Oliver Laumann
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3, or (at your option)
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program (see the file COPYING); if not, see
26 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
29 ****************************************************************
32 /* Deals with the list of displays */
37 #include "list_generic.h"
41 extern struct layer
*flayer
;
42 extern struct display
*display
, *displays
;
43 extern struct mchar mchar_blank
, mchar_so
;
45 static char ListID
[] = "display";
48 * layout of the displays page is as follows:
50 xterm 80x42 jnweiger@/dev/ttyp4 0(m11) &rWx
51 facit 80x24 nb mlschroe@/dev/ttyhf 11(tcsh) rwx
52 xterm 80x42 jnhollma@/dev/ttyp5 0(m11) &R.x
54 | | | | | | | | ¦___ window permissions
55 | | | | | | | | (R. is locked r-only,
56 | | | | | | | | W has wlock)
57 | | | | | | | |___ Window is shared
58 | | | | | | |___ Name/Title of window
59 | | | | | |___ Number of window
60 | | | | |___ Name of the display (the attached device)
61 | | | |___ Username who is logged in at the display
62 | | |___ Display is in nonblocking mode. Shows 'NB' if obuf is full.
63 | |___ Displays geometry as width x height.
64 |___ the terminal type known by screen for this display.
69 gl_Display_header(struct ListData
*ldata
)
71 leftline("term-type size user interface window Perms", 0, 0);
72 leftline("---------- ------- ---------- ----------------- ---------- -----", 1, 0);
77 gl_Display_footer(struct ListData
*ldata
)
79 centerline("[Press Space to refresh; Return to end.]", flayer
->l_height
- 1);
83 gl_Display_row(struct ListData
*ldata
, struct ListRow
*lrow
)
85 struct display
*d
= lrow
->data
;
87 static char *blockstates
[5] = {"nb", "NB", "Z<", "Z>", "BL"};
88 struct win
*w
= d
->d_fore
;
89 struct mchar m_current
= mchar_blank
;
90 m_current
.attr
= A_BD
;
92 sprintf(tbuf
, " %-10.10s%4dx%-4d%10.10s@%-16.16s%s",
93 d
->d_termname
, d
->d_width
, d
->d_height
, d
->d_user
->u_name
,
95 (d
->d_blocked
|| d
->d_nonblock
>= 0) && d
->d_blocked
<= 4 ? blockstates
[d
->d_blocked
] : " ");
99 int l
= 10 - strlen(w
->w_title
);
102 sprintf(tbuf
+ strlen(tbuf
), "%3d(%.10s)%*s%c%c%c%c",
103 w
->w_number
, w
->w_title
, l
, "",
104 /* w->w_dlist->next */ 0 ? '&' : ' ',
107 * -,r,R no read, read, read only due to foreign wlock
108 * -,.,w,W no write, write suppressed by foreign wlock,
110 * -,x no execute, execute
113 (AclCheckPermWin(d
->d_user
, ACL_READ
, w
) ? '-' :
114 ((w
->w_wlock
== WLOCK_OFF
|| d
->d_user
== w
->w_wlockuser
) ?
116 (AclCheckPermWin(d
->d_user
, ACL_READ
, w
) ? '-' :
117 ((w
->w_wlock
== WLOCK_OFF
) ? 'w' :
118 ((d
->d_user
== w
->w_wlockuser
) ? 'W' : 'v'))),
119 (AclCheckPermWin(d
->d_user
, ACL_READ
, w
) ? '-' : 'x')
125 leftline(tbuf
, lrow
->y
, lrow
== ldata
->selected
? &mchar_so
: d
== display
? &m_current
: 0);
131 gl_Display_rebuild(struct ListData
*ldata
)
133 /* recreate the rows */
135 struct ListRow
*row
= NULL
;
136 for (d
= displays
; d
; d
= d
->d_next
)
138 row
= glist_add_row(ldata
, d
, row
);
140 ldata
->selected
= row
;
143 glist_display_all(ldata
);
147 gl_Display_input(struct ListData
*ldata
, char **inp
, int *len
)
149 struct display
*cd
= display
;
152 if (!ldata
->selected
)
155 ch
= (unsigned char) **inp
;
161 case ' ': /* Space to refresh */
162 glist_remove_rows(ldata
);
163 gl_Display_rebuild(ldata
);
173 case 'd': /* Detach */
174 case 'D': /* Power detach */
175 display
= ldata
->selected
->data
;
176 if (display
== cd
) /* We do not allow detaching the current display */
180 ch
== 'D' ? D_REMOTE_POWER
: D_REMOTE
186 glist_remove_rows(ldata
);
187 gl_Display_rebuild(ldata
);
192 /* We didn't actually process the input. */
201 gl_Display_freerow(struct ListData
*ldata
, struct ListRow
*row
)
203 /* There was no allocation when row->data was set. So nothing to do here. */
208 gl_Display_free(struct ListData
*ldata
)
210 /* There was no allocation in ldata->data. So nothing to do here. */
214 static struct GenericList gl_Display
=
222 NULL
/* We do not allow searching in the display list, at the moment */
228 struct ListData
*ldata
;
229 if (flayer
->l_width
< 10 || flayer
->l_height
< 5)
231 LMsg(0, "Window size too small for displays page");
235 ldata
= glist_display(&gl_Display
, ListID
);
239 gl_Display_rebuild(ldata
);