Newer
Older
/*
* BRLTTY - A background process providing access to the console screen (when in
* text mode) for a blind person using a refreshable braille display.
*
* Copyright (C) 1995-2018 by The BRLTTY Developers.
*
* BRLTTY comes with ABSOLUTELY NO WARRANTY.
*
* This is free software, placed under the terms of the
* GNU Lesser General Public License, as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any
* later version. Please see the file LICENSE-LGPL for details.
*
* This software is maintained by Dave Mielke <dave@mielke.cc>.
*/
/* scr.cc - The screen reading library
*
* Note: Although C++, this code requires no standard C++ library.
* This is important as BRLTTY *must not* rely on too many
* run-time shared libraries, nor be a huge executable.
*/
#include "prologue.h"
#include <string.h>
MainScreen mainScreen;
BaseScreen *currentScreen = &mainScreen.base;
return currentScreen == &mainScreen.base;
}
const char *const *
getScreenParameters (const ScreenDriver *driver) {
return driver->parameters;
}
const DriverDefinition *
getScreenDriverDefinition (const ScreenDriver *driver) {
return &driver->definition;
}
initializeScreen (void) {
screen->initialize(&mainScreen);
}
void
setNoScreen (void) {
screen = &noScreen;
initializeScreen();
}
constructScreenDriver (char **parameters) {
initializeScreen();
if (mainScreen.processParameters(parameters)) {
if (mainScreen.construct()) {
return 1;
} else {
logMessage(LOG_DEBUG, "screen driver initialization failed: %s",
screen->definition.code);
}
mainScreen.releaseParameters();
}
void
destructScreenDriver (void) {
mainScreen.destruct();
mainScreen.releaseParameters();
}
int
pollScreen (void) {
return currentScreen->poll();
}
int
refreshScreen (void) {
return currentScreen->refresh();
}
void
describeScreen (ScreenDescription *description) {
describeBaseScreen(currentScreen, description);
readScreen (short left, short top, short width, short height, ScreenCharacter *buffer) {
ScreenBox box;
box.left = left;
box.top = top;
box.width = width;
box.height = height;
return currentScreen->readCharacters(&box, buffer);
readScreenText (short left, short top, short width, short height, wchar_t *buffer) {
unsigned int count = width * height;
ScreenCharacter characters[count];
if (!readScreen(left, top, width, height, characters)) return 0;
{
int i;
for (i=0; i<count; ++i) buffer[i] = characters[i].text;
}
logMessage(LOG_CATEGORY(SCREEN_DRIVER), "insert key: 0X%04X", key);
routeScreenCursor (int column, int row, int screen) {
return currentScreen->routeCursor(column, row, screen);
}
int
highlightScreenRegion (int left, int right, int top, int bottom) {
return currentScreen->highlightRegion(left, right, top, bottom);
unhighlightScreenRegion (void) {
return currentScreen->unhighlightRegion();
getScreenPointer (int *column, int *row) {
return currentScreen->getPointer(column, row);
return currentScreen->selectVirtualTerminal(vt);
return currentScreen->switchVirtualTerminal(vt);
}
int
currentVirtualTerminal (void) {
return currentScreen->currentVirtualTerminal();
}
int
userVirtualTerminal (int number) {
return mainScreen.userVirtualTerminal(number);
handleScreenCommands (int command, void *data) {
return currentScreen->handleCommand(command);
KeyTableCommandContext
getScreenCommandContext (void) {
return currentScreen->getCommandContext();
}
/* This function should be used in a forked process. Though we want to
* have a separate file descriptor for the main screen from the one used
* in the main thread. So we close and reopen the device.
*/
mainScreen.destruct();
return mainScreen.construct();
destructRoutingScreen (void) {
mainScreen.destruct();