void vga_movecursor(void *cons, int row, int col) { unsigned int curLoc; struct vga_console *vga; vga = (struct vga_console *)cons; /* * check whether the row is valid. if not we wrap around * to row 0, similarly for column. */ vga->row = row; vga->col = col; if (!VALID_ROW(vga->row)) vga->row = 0; if (!VALID_COL(vga->col)) vga->col = 0; curLoc = vga->row * VGA_COLS + vga->col; outb(VIDEO_ADDR_REG, VIDEO_CURSOR_LOC_HIGH); outb(VIDEO_DATA_REG, curLoc >> 8); outb(VIDEO_ADDR_REG, VIDEO_CURSOR_LOC_LOW); outb(VIDEO_DATA_REG, curLoc & 0x00FF); } /* end of vga_movecursor */
short _DtTermPrimBufferGetTextWc ( const TermBuffer tb, const short row, const short col, const short length, char *buffer, const Boolean needWideChar ) { short len; if (!VALID_ROW(tb, row) || !VALID_COL(tb, col)) { return(0); } len = MIN(length, LENGTH(LINES(tb)[row]) - col); if (length > 0) { memcpy(buffer, BUFFER(LINES(tb)[row]) + col, len); } return(len); }
static gboolean etss_is_cell_editable (ETableModel *etm, gint col, gint row) { ETableSubset *etss = (ETableSubset *) etm; g_return_val_if_fail (VALID_ROW (etss, row), FALSE); return e_table_model_is_cell_editable (etss->source, col, MAP_ROW (etss, row)); }
static gchar * etss_get_save_id (ETableModel *etm, gint row) { ETableSubset *etss = (ETableSubset *) etm; g_return_val_if_fail (VALID_ROW (etss, row), NULL); if (e_table_model_has_save_id (etss->source)) return e_table_model_get_save_id (etss->source, MAP_ROW (etss, row)); else return g_strdup_printf ("%d", MAP_ROW(etss, row)); }
static gpointer etss_value_at (ETableModel *etm, gint col, gint row) { ETableSubset *etss = (ETableSubset *) etm; g_return_val_if_fail (VALID_ROW (etss, row), NULL); etss->last_access = row; d(g_print("g) Setting last_access to %d\n", row)); return e_table_model_value_at (etss->source, col, MAP_ROW (etss, row)); }
static void etss_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer val) { ETableSubset *etss = (ETableSubset *) etm; g_return_if_fail (VALID_ROW (etss, row)); etss->last_access = row; d(g_print("h) Setting last_access to %d\n", row)); e_table_model_set_value_at (etss->source, col, MAP_ROW (etss, row), val); }
int check_diag(int row, int col, int x, int y) { int count = 0; row = row + x; col = col + y; if (VALID_ROW(row) && VALID_COL(col)) { if (board[row][col] == QUEEN) count++; count += check_diag(row, col, x, y); } return count; }
/* ** Clear the line to the new width (just reset the line width). */ Boolean _DtTermPrimBufferClearLineWc ( const TermBuffer tb, const short row, short newWidth ) { TermLine line; TermCharInfoRec charInfo; short newLength; /* ** Some simple bounds checking. */ if (!VALID_ROW(tb, row)) { return(False); } /* ** force the width to the desired value ** ** (We take the direct approach because _DtTermPrimBufferSetLineWidth ** doesn't allow the line width to decrease.) */ line = LINE_OF_TBUF(tb, row); /* ** if this line is part of the selection, disown the selection... */ if (IS_IN_SELECTION(line, MIN(newWidth, WIDTH(line)), MAX(newWidth, WIDTH(line)))) { (void) _DtTermPrimSelectDisown(WIDGET(tb)); } /* ** Clip the new width to the buffer width. */ newWidth = MIN(newWidth, COLS(tb)); if (newWidth < WIDTH(line)) { if (newWidth == 0) { newLength = 0; } else { /* ** handle the case of clearing the second column of a two column ** character... */ _DtTermPrimGetCharacterInfo(tb, row, MAX(0, newWidth - 1), &charInfo); if ((charInfo.width == 2 ) && (charInfo.startCol == MAX(0, newWidth - 1))) { /* ** we are clearing column 2 of 2, replace column 1 of 1 with ** a space... */ *charInfo.u.pwc = L' '; } newLength = charInfo.idx + 1; } /* ** Call the helper function if it exists */ if (CLEAR_LINE(tb)) { (*CLEAR_LINE(tb))(tb, row, newWidth); } WRAPPED(line) = False; WIDTH(line) = newWidth; LENGTH(line) = newLength; } return(True); }
void _DtTermPrimBufferDeleteWc ( TermBuffer tb, short *row, short *col, short *width, termChar **returnChars, /* pointer to delete buffer */ short *returnCount /* count of bytes in delete buffer */ ) { int copyCount; TermLine line; short localRow; short localCol; TermCharInfoRec startCharInfo; TermCharInfoRec stopCharInfo; if (!VALID_ROW(tb, *row) || !VALID_COL(tb, *col)) { if (returnChars) { *returnChars = NULL; *returnCount = 0; } return; } /* ** save some local copies, to originals may get modified */ localRow = *row; localCol = *col; line = LINE_OF_TBUF(tb, *row); *width = MAX(0, MIN(WIDTH(line) - localCol, *width)); /* ** there are 3 cases of deleting a character from a line: ** Case 1: ** the cursor is at least 2 positions past the end of the ** line (col - WIDTH(line) > 0) ** ** Case 2: ** the cursor is in the middle of the line (copyCount > 0) ** - move the remaining characters to the left ** - deleteEnhancement ** - adjust WIDTH and LENGTH ** ** Case 3: ** the cursor is at the end of the line (copyCount == 0 and ** col == WIDTH(line)) ** - deleteEnhancement ** - adjust WIDTH and LENGTH */ if (localCol >= WIDTH(line) || *width == 0) { /* ** Handle Case 1... */ if (returnChars) { *returnChars = NULL; *returnCount = 0; } return; } /* ** make any necessary adjustments to 2 column characters... */ _patchUpChar(tb, *row, col, &startCharInfo); (void) _DtTermPrimGetCharacterInfo(tb, localRow, MIN(WIDTH(line), localCol + *width), &stopCharInfo); if ((stopCharInfo.width == 2) && (stopCharInfo.startCol == localCol + *width - 1)) { /* ** do not try to delete column 1 of 2... ** ** replace the 2 column character with two one column spaces... */ *stopCharInfo.u.pwc = L' '; memmove(stopCharInfo.u.pwc + 1, stopCharInfo.u.pwc, (LENGTH(line) - stopCharInfo.idx) * sizeof(wchar_t)); /* ** now make stopCharInfo point at the new space */ stopCharInfo.width = 1; stopCharInfo.startCol++; stopCharInfo.u.pwc++; stopCharInfo.idx++; LENGTH(line)++; } /* ** Save the current characters before we overwrite them ** (if returnChars is non-NULL 0) */ if (returnChars != NULL) { *returnCount = (stopCharInfo.idx - startCharInfo.idx) * sizeof(wchar_t); *returnChars = (termChar *)XtMalloc(*returnCount); memmove(*returnChars, startCharInfo.u.pwc, *returnCount); } /* ** Cases 2, 3, and 4 require that we delete the enhancement... */ if (DELETE_ENH(tb)) { (*DELETE_ENH(tb))(tb, localRow, localCol, *width); } copyCount = MAX(0, LENGTH(line) - stopCharInfo.idx); if (copyCount > 0) { /* ** handle case 2 */ memmove(startCharInfo.u.pwc, stopCharInfo.u.pwc, copyCount * sizeof(wchar_t)); } /* ** Cases 2 and 3 require that we decrement the line length... */ WIDTH(line) -= *width; LENGTH(line) -= (stopCharInfo.idx - startCharInfo.idx); /* ** update info we need to return... */ *width = stopCharInfo.startCol - startCharInfo.startCol; }
/* ** Insert as many characters as possible at the specified row,col ** return a count of the number of characters bumped off the end of the line ** in 'returnLength' and a pointer to a buffer containing those characters ** 'returnChars'. ** ** The the new column width of the line is returned as the value of the ** function. ** ** NOTES: ** We are trying to implement mechanism and not policy. This ** routine does a minimum of checking for boundary conditions. */ short _DtTermPrimBufferInsertWc ( const TermBuffer tb, const short row, const short col, wchar_t *newChars, short numChars, Boolean insertFlag, /* if TRUE, insert, else overwrite */ termChar **returnChars, /* pointer to overflow buffer */ short *returnLength /* count of characters in overflow buffer */ ) { short widthInc; /* incremental change in line width */ short lengthInc; /* incremental change in line length */ short widthInsert; /* column width of chars inserted */ short localCol; TermLine line; if (!VALID_ROW(tb, row) || !VALID_COL(tb, col)) { *returnLength = 0; return(0); } if (isDebugFSet('i', 1)) { #ifdef BBA #pragma BBA_IGNORE #endif /*BBA*/ (void) _termBufferValidateLineWc(tb, row); } line = LINE_OF_TBUF(tb, row); localCol = col; if (WIDTH(line) < col) { /* ** We're adding characters past the current end of line, ** pad it out. */ _DtTermPrimBufferPadLineWc(tb, row, col); } /* ** It doesn't matter if we're overwriting, or inserting at the end ** of the line, the result is the same... */ if (insertFlag == False || col == WIDTH(line)) { _primBufferOverwriteWc(tb, row, &localCol, newChars, numChars, &lengthInc, &widthInc, &widthInsert, *returnChars, returnLength); } else { _primBufferInsertWc(tb, row, &localCol, newChars, numChars, &lengthInc, &widthInc, &widthInsert, *returnChars, returnLength); } /* ** Everything's ready: ** - put the characters into the line ** - adjust the line width (_DtTermPrimBufferSetLineWidth won't ** let the line get shorter)... ** - adjust the line length ** - update the enhancements */ WIDTH(line) += widthInc; LENGTH(line) += lengthInc; /* ** fix up the enhancments... */ if (INSERT_ENH(tb)) { (*INSERT_ENH(tb))(tb, row, col, widthInsert, insertFlag); } if (isDebugFSet('i', 1)) { #ifdef BBA #pragma BBA_IGNORE #endif /*BBA*/ (void) _termBufferValidateLineWc(tb, row); } return(WIDTH(line)); }