static int writeCells (BrailleDisplay *brl) { unsigned int textCount = brl->textColumns; unsigned int statusCount = brl->statusColumns; unsigned char cells[textCount + statusCount]; unsigned char *cell = cells; while (textCount) *cell++ = translateOutputCell(textCells[--textCount]); while (statusCount) *cell++ = translateOutputCell(statusCells[--statusCount]); return io->methods->writeCells(brl, cells, cell-cells); }
static int brl_writeWindow(BrailleDisplay *brl, const wchar_t *text) { if(text) { char bytes[brl->textColumns]; int i; for(i = 0; i < brl->textColumns; ++i) { wchar_t character = text[i]; bytes[i] = iswLatin1(character)? character: '?'; } braille_write(bytes, brl->textColumns); if(brl->cursor >= 0) { braille_filter(translateOutputCell(cursorDots()), brl->cursor); } braille_render(); } return 1; }
static int writeLine (BrailleDisplay *brl) { unsigned char packet[2 + (brl->textColumns * 2)]; unsigned char *byte = packet; *byte++ = statusCells[gscScreenCursorRow]; *byte++ = statusCells[gscScreenCursorColumn]; { int i; for (i=0; i<brl->textColumns; i+=1) { *byte++ = translateOutputCell(brl->buffer[i]); *byte++ = 0X07; } } if (showOutputMapping) { int row = statusCells[gscBrailleWindowRow]; if (--row < 0X10) { int column; for (column=0; column<80; column+=1) packet[2+(column*2)] = ' '; for (column=0; column<0X10; column+=1) { unsigned char *byte = &packet[2 + (column * 8)]; static const unsigned char hex[] = "0123456789ABCDEF"; *byte = hex[row]; byte += 2; *byte = hex[column]; byte += 2; *byte = (row << 4) | column; } } } return writePacket(brl, packet, byte-packet); }
static int brl_writeWindow (BrailleDisplay *brl, const wchar_t *text) { if (cellsHaveChanged(brl->data->textCells, brl->buffer, brl->textColumns, NULL, NULL, &brl->data->forceRewrite)) { unsigned char bytes[(brl->textColumns * 2) + 2]; unsigned char *byte = bytes; { int i; for (i=brl->textColumns-1; i>=0; i-=1) { *byte++ = 0XFC; *byte++ = translateOutputCell(brl->data->textCells[i]); } } *byte++ = 0XFD; *byte++ = 0X10; if (!writeBytes(brl, bytes, byte-bytes)) return 0; } return 1; }