Debian Codegraph @

terps/alan2/term.c

raw symbols SCIP
1 /*----------------------------------------------------------------------*\
2
3 term.c
4
5 System dependent terminal oriented functions for ALAN interpreter ARUN
6
7 \*----------------------------------------------------------------------*/
8
9 #include "main.h"
10
11 #include "term.h"
12
13
14 /*======================================================================
15
16 getPageSize()
17
18 Try to get the current page size from the system, else use the ones
19 from the header.
20
21 */
22 #ifdef _PROTOTYPES_
23 void getPageSize(void)
24 #else
25 void getPageSize()
26 #endif
27 {
28 #ifdef GLK
29 paglen = 0;
30 pagwidth = 0;
31
32 #else
33 #ifdef HAVE_TERMIO
34
35 #include <sys/termios.h>
36
37 extern int ioctl();
38
39 struct winsize win;
40 int ecode;
41
42 ecode = ioctl(1, TIOCGWINSZ, &win);
43
44 if (ecode != 0 || win.ws_row == 0)
45 paglen = header->paglen;
46 else
47 paglen = win.ws_row;
48
49 if (ecode != 0 || win.ws_col == 0)
50 pagwidth = header->pagwidth;
51 else
52 pagwidth = win.ws_col;
53
54 #else
55 #ifdef __amiga__
56 #include <libraries/dosextens.h>
57 #include <intuition/intuition.h>
58 #include <graphics/text.h>
59 #include <clib/exec_protos.h>
60
61 struct Process * proc;
62 struct InfoData *id;
63 struct Window *win;
64 struct TextFont *textFont;
65 struct StandardPacket *packet;
66
67 proc = (struct Process *) FindTask(0L);
68
69 id = (struct InfoData *) allocate(sizeof(struct InfoData));
70
71 if (proc->pr_ConsoleTask) {
72 packet = (struct StandardPacket *) allocate(sizeof(struct StandardPacket));
73 packet->sp_Msg.mn_Node.ln_Name = (char *)&(packet->sp_Pkt);
74 packet->sp_Pkt.dp_Link = & packet->sp_Msg;
75 packet->sp_Pkt.dp_Port = & proc->pr_MsgPort;
76 packet->sp_Pkt.dp_Type = ACTION_DISK_INFO;
77
78 packet->sp_Pkt.dp_Arg1 = ((LONG) id) >> 2;
79
80 PutMsg ((struct MsgPort *) proc->pr_ConsoleTask, & packet->sp_Msg);
81 WaitPort(&proc->pr_MsgPort);
82 GetMsg(&proc->pr_MsgPort);
83 free((char *)packet);
84
85 win = (struct Window *) id->id_VolumeNode;
86 free(id);
87
88 /* Calculate number of characters and lines w.r.t font size and borders */
89 textFont = win->IFont;
90 paglen = win->Height/textFont->tf_YSize-2;
91 pagwidth = win->Width/textFont->tf_XSize-3;
92 } else {
93 paglen = header->paglen;
94 pagwidth = header->pagwidth;
95 }
96
97 #else
98
99 paglen = header->paglen;
100 pagwidth = header->pagwidth;
101
102 #endif
103 #endif
104 #endif
105 }