public interface ScreenDriver<O extends OutputManager<?>>
This interface contains all implementation-specific methods which should be
implemented from scratch for each particular driver implementation. The part
of the driver which is more hardware independent is listed in
OutputPrimitives
interface and DriverPrimitives
abstract
class.
General requirements to the implementation:
At present only character based UI is supported. Therefore, all interaction
with the driver assumes existence of some kind of character-based terminal.
All coordinates passed are coordinates of the character row and column (Y and
X respectively). All coordinates are 0-based and Y axis has down direction.
Upper left corner has coordinates (0,0) and lower right -
(@link OutputPrimitives#screenWidth()} - 1,
{OutputPrimitives.screenHeight()
- 1). There is no limitations on
actual terminal size, but at present dynamic screen size change is not
supported - once application starts it assumes that terminal has fixes size
which remains stable until application if finished. Particular implementation
may return terminal screen size different than phisical screen size, but
in this case it is responsible for handling of necessary
scrolling/panning/clipping, because P2J has no support for this funtionality
and assumes that entire reported by driver screen area is visible to user.
Note that requirement for fixed size of terminal screen applies even if
terminal is suspended and then resumed. Handling size changes (if necessary)
is up to the driver implementation.
Modifier and Type | Method and Description |
---|---|
void |
beep()
Provide an audible feedback to user by generating a beep signal.
|
boolean |
captureMouseEvents(boolean state)
Enable or disable capture of mouse events.
|
void |
clear()
Clear screen.
|
default void |
clientReady()
Notify the driver that the client is ready (useful for embedded mode, to notify the embedded
app the client can handle messages).
|
O |
createOutputManager(BootstrapConfig cfg)
Get the
OutputManager instance associated with this driver. |
ChildProcessFactory |
getChildProcessFactory()
Get driver-specific child process factory.
|
WidgetFactory<?> |
getFactory()
Get driver-specific widget factory.
|
OutputPrimitives |
getPrimitives()
Get driver-specific direct output primitives implementation.
|
java.lang.String |
getWindowSystem()
Get the default WINDOW-SYSTEM used by this driver.
|
void |
handleMouseEvent(int sourceID,
java.awt.event.MouseEvent evt)
Handle the specified event, in the context of the specified widget.
|
boolean |
inBackgroundMode()
Checks if the current driver is running in background mode.
|
boolean |
inBatchMode()
Checks if the current driver is running in batch mode.
|
void |
init()
Driver initialization.
|
boolean |
isChui()
Get screen interface type.
|
default void |
lockMousePointer(int widgetId,
MousePtrWrapper ptr)
Lock the mouse pointer (suppress widget-specific changes) or unlock it
|
default void |
openURL(java.lang.String path)
Opens the target page or resource in a browser's window.
|
default void |
propagate(int windowId,
int wid,
MousePtrWrapper ptr)
Push information about the loaded mouse pointer for widget
|
int |
readKey()
Read single keystroke from keyboard.
|
void |
resetMode()
Reset current screen mode.
|
void |
resume()
Resume normal driver operation.
|
boolean |
setCursorStatus(boolean on)
Set cursor status (ON/OFF).
|
void |
setTerminalType(java.lang.String name)
Change terminal type to specified one.
|
void |
shutdown()
Perform driver shutdown.
|
void |
suspend()
Suspend all screen I/O operations.
|
java.lang.String |
terminalType()
Obtain system/implementation specific terminal type string.
|
O createOutputManager(BootstrapConfig cfg)
OutputManager
instance associated with this driver.cfg
- The initial configuration for this driver.boolean setCursorStatus(boolean on) throws java.lang.IllegalStateException
The implementation of this method should show/hide actual screen cursor visible to user. Remaining code assumes that actual cursor status visible to user is properly changed upon exit from this method.
on
- true
- show cursor, false
- hide cursor.true
if operation was successful.java.lang.IllegalStateException
void clear()
This method should clear the screen and perform necessary flushing of the system-specific buffers if necessary. Users of this method assume that actual screen appearance as it is visible to the user is properly changed upon exit from this method.
void beep()
There is no specific requirements to this method and actual implementation may do nothing if there is no way to perform audible notification to the user.
boolean inBatchMode()
true
for batch mode, false
otherwise.boolean inBackgroundMode()
true
for background mode, false
otherwise.int readKey()
The list of codes and detailed description is provided in Keyboard
class. The KeyProcessor
can serve as an example of the key
translation implementation.
void resetMode()
Upon exit from this method P2J assumes that screen is in correct state and can be used for interaction with the user.
void suspend()
void resume()
java.lang.String terminalType()
At present this is used to implement 4GL TERMINAL function and do some terminal-specific workarounds. At present workarounds exist for "vt320" terminal type. If implementation requires no special workarounds, then it should avoid returning "vt320" as terminal type string.
void setTerminalType(java.lang.String name)
name
- OutputPrimitives getPrimitives()
WidgetFactory<?> getFactory()
ChildProcessFactory getChildProcessFactory()
void init()
java.lang.String getWindowSystem()
ClientParameters
for the list
of possible values.boolean isChui()
true
is ChUI false
is GUIboolean captureMouseEvents(boolean state)
state
- true
to capture mouse events, false
to ignore them.void handleMouseEvent(int sourceID, java.awt.event.MouseEvent evt)
sourceID
- The source widget ID.evt
- The mouse event.void shutdown()
default void lockMousePointer(int widgetId, MousePtrWrapper ptr)
widgetId
- the id of the active DropDown which caused the pointer lock or -1ptr
- the locked mouse pointer or null
for unlockdefault void propagate(int windowId, int wid, MousePtrWrapper ptr)
windowId
- to level window idwid
- widgetIdptr
- mouse pointerdefault void openURL(java.lang.String path)
path
- The url path to the target resource.default void clientReady()