18.10.2014 Views

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

330 TUI the implementation<br />

23.2.1 Constants used <strong>in</strong> the TUI<br />

The TUI uses several constants to def<strong>in</strong>e the state of the TUI and its environment. The size of the screen and the<br />

maximum size of w<strong>in</strong>dows created on the screen are def<strong>in</strong>ed by:<br />

package Pack_Constants is<br />

Vdt_Max_X : constant := 79; --Columns on VDT<br />

Vdt_Max_Y : constant := 25; --L<strong>in</strong>es on VDT<br />

W<strong>in</strong>dow_Max_X : constant := 79; --MAX columns w<strong>in</strong>dow<br />

W<strong>in</strong>dow_Max_Y : constant := 25; --MAX l<strong>in</strong>es w<strong>in</strong>dow<br />

Various special characters that can be sent to or are used by the TUI, have the follow<strong>in</strong>g values:<br />

C_Cursor<br />

C_Blank<br />

C_W<strong>in</strong>_A<br />

C_W<strong>in</strong>_Pas<br />

C_Exit<br />

C_Where<br />

C_Action<br />

C_Switch<br />

C_Menu<br />

C_Del<br />

: constant Character := '*';<br />

: constant Character := ' ';<br />

: constant Character := '#';<br />

: constant Character := '+';<br />

: constant Character := Character'Val(05); --^E<br />

: constant Character := Character'Val(255);<br />

: constant Character := Character'Val(13); --cr<br />

: constant Character := Character'Val(09); --ht<br />

: constant Character := Character'Val(27); --esc<br />

: constant Character := Character'Val(08); --^B<br />

Various <strong>in</strong>ternal states and representations of actions are def<strong>in</strong>ed <strong>in</strong> the list below. In this list, the arrow keys<br />

that a user presses to <strong>in</strong>teract with the TUI are <strong>in</strong>ternally def<strong>in</strong>ed as a s<strong>in</strong>gle character. This is to simplify the<br />

<strong>in</strong>ternal code that processes the key's representations.<br />

C_No_Char<br />

: constant Character := Character'Val(00);<br />

C_Left : constant Character := Character'Val(12); --^L<br />

C_Right : constant Character := Character'Val(18); --^R<br />

C_Up : constant Character := Character'Val(21); --^U<br />

C_Down : constant Character := Character'Val(04); --^D<br />

end Pack_Constants;<br />

23.2.2 Raw <strong>in</strong>put and output<br />

The TUI works on the assumption that a character is sent immediately to the screen without any <strong>in</strong>ternal<br />

process<strong>in</strong>g or buffer<strong>in</strong>g. Likewise, the TUI receives each character as it is typed without any <strong>in</strong>ternal buffer<strong>in</strong>g or<br />

process<strong>in</strong>g.<br />

An <strong>Ada</strong> package specification and possible implementation are shown below. In this implementation, a library<br />

procedure C_No_Echo written <strong>in</strong> the language C is used to turn off the echo<strong>in</strong>g of the character that is read<br />

immediately from the keyboard.<br />

© M A Smith - May not be reproduced without permission

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!