/* ---------------------------------------------------------------------- */ static void fill_grid(mxArray *G, struct processed_grid *grid) /* ---------------------------------------------------------------------- */ { double *pr; pr = mxGetPr(mxGetField(G, 0, "cartDims")); pr[0] = grid->dimensions[0]; pr[1] = grid->dimensions[1]; pr[2] = grid->dimensions[2]; fill_nodes(mxGetField(G, 0, "nodes"), grid); fill_faces(mxGetField(G, 0, "faces"), grid); fill_cells(mxGetField(G, 0, "cells"), grid); }
END_TEST START_TEST (test_nb) { freesasa_set_verbosity(FREESASA_V_SILENT); ck_assert_ptr_eq(cell_list_new(1,&coord),NULL); ck_assert_int_eq(fill_cells(&a_cell_list,&coord),FREESASA_FAIL); ck_assert_ptr_eq(freesasa_nb_alloc(10),NULL); for (int i = 1; i < 50; ++i) { set_fail_freq(i); ck_assert_ptr_eq(freesasa_nb_alloc(2*i),NULL); set_fail_freq(i); ck_assert_ptr_eq(freesasa_nb_new(&coord,r),NULL); } set_fail_freq(1); freesasa_set_verbosity(FREESASA_V_NORMAL); }
static int wadd_wch_literal(WINDOW *win, cchar_t ch) { int x; int y; struct ldat *line; x = win->_curx; y = win->_cury; CHECK_POSITION(win, x, y); ch = render_char(win, ch); line = win->_line + y; CHANGED_CELL(line, x); /* * Non-spacing characters are added to the current cell. * * Spacing characters that are wider than one column require some display * adjustments. */ { int len = wcwidth(CharOf(ch)); int i; int j; wchar_t *chars; if (len == 0) { /* non-spacing */ if ((x > 0 && y >= 0) || (win->_maxx >= 0 && win->_cury >= 1)) { if (x > 0 && y >= 0) chars = (win->_line[y].text[x - 1].chars); else chars = (win->_line[y - 1].text[win->_maxx].chars); for (i = 0; i < CCHARW_MAX; ++i) { if (chars[i] == 0) { TR(TRACE_VIRTPUT, ("added non-spacing %d: %x", x, (int) CharOf(ch))); chars[i] = CharOf(ch); break; } } } goto testwrapping; } else if (len > 1) { /* multi-column characters */ /* * Check if the character will fit on the current line. If it does * not fit, fill in the remainder of the line with blanks. and * move to the next line. */ if (len > win->_maxx + 1) { TR(TRACE_VIRTPUT, ("character will not fit")); return ERR; } else if (x + len > win->_maxx + 1) { int count = win->_maxx + 1 - x; TR(TRACE_VIRTPUT, ("fill %d remaining cells", count)); fill_cells(win, count); if (wrap_to_next_line(win) == ERR) return ERR; x = win->_curx; y = win->_cury; line = win->_line + y; } /* * Check for cells which are orphaned by adding this character, set * those to blanks. * * FIXME: this actually could fill j-i cells, more complicated to * setup though. */ for (i = 0; i < len; ++i) { if (isWidecBase(win->_line[y].text[x + i])) { break; } else if (isWidecExt(win->_line[y].text[x + i])) { for (j = i; x + j <= win->_maxx; ++j) { if (!isWidecExt(win->_line[y].text[x + j])) { TR(TRACE_VIRTPUT, ("fill %d orphan cells", j)); fill_cells(win, j); break; } } break; } } /* * Finally, add the cells for this character. */ for (i = 0; i < len; ++i) { cchar_t value = ch; SetWidecExt(value, i); TR(TRACE_VIRTPUT, ("multicolumn %d:%d (%d,%d)", i + 1, len, win->_begy + y, win->_begx + x)); line->text[x] = value; CHANGED_CELL(line, x); ++x; } goto testwrapping; } } /* * Single-column characters. */ line->text[x++] = ch; /* * This label is used only for wide-characters. */ testwrapping: TR(TRACE_VIRTPUT, ("cell (%ld, %ld..%d) = %s", (long) win->_cury, (long) win->_curx, x - 1, _tracech_t(CHREF(ch)))); if (x > win->_maxx) { return wrap_to_next_line(win); } win->_curx = (NCURSES_SIZE_T) x; return OK; }
void process_mouse() { Dword mouse_btn, ckeys, shift, ctrl; int mouse_x, mouse_y, i, dx = 0, dy = 0; int redraw = 0; Dword mySlot = kos_GetSlotByPID(myPID); if (kos_GetActiveSlot() != mySlot) return; edit_box_mouse((dword)&cell_box); edit_box_mouse((dword)&file_box); int vert, hor; kos_GetScrollInfo(vert, hor); //sprintf(debuf, "scroll %U %U", vert, hor); //rtlDebugOutString(debuf); if (vert != 0) //труъ перерисовка! { if (!((sel_end_y + vert) >= (row_count-1))) //заглушка move_sel(sel_x, sel_y + vert); return; } kos_GetMouseState(mouse_btn, mouse_x, mouse_y); mouse_x -= 5; mouse_y -= kos_GetSkinHeight(); mouse_btn &= 0x0001; ckeys = kos_GetSpecialKeyState(); shift = ckeys & 0x3; if (mouse_y < 0 && mouse_btn) // т.к. мышка на заголовке окна { window_is_dragged = 1; return; } if (window_is_dragged) { if (mouse_btn) return; else window_is_dragged = 0; } if (!size_state && !mouse_btn) return; if (mouse_btn && !size_state) // LMB down { //rtlDebugOutString("lmb down and not resize"); if (mouse_x >= drag_x && mouse_x <= drag_x + 4 && mouse_y >= drag_y && mouse_y <= drag_y + 4) { size_state = SIZE_DRAG; old_end_x = sel_end_x; old_end_y = sel_end_y; } else if (mouse_y <= row_height[0]) { //rtlDebugOutString("can resize cols"); int kx = -1, i; for (i = 0; i < col_count - 1; i++) if (mouse_x >= col_left[i] + col_width[i] - 5 && mouse_x <= col_left[i + 1] + 5) { kx = i; break; } if (kx != -1) { //sprintf(debuf,"size x %U",k); //rtlDebugOutString(debuf); size_id = kx; size_state = SIZE_X; } } else if (mouse_x <= col_width[0]) { int ky = -1; for (i = 0; i < row_count - 1; i++) if (mouse_y >= row_top[i] + row_height[i] - 5 && mouse_y <= row_top[i + 1] + 5) { ky = i; break; } if (ky != -1) { size_id = ky; size_state = SIZE_Y; } } else // кликнута ячейка if (mouse_x <= col_left[nx - 1] && mouse_y <= row_top[ny - 1]) { was_single_selection = sel_x == sel_end_x && sel_y == sel_end_y; int kx = -1, i; for (i = 0; i < col_count - 1; i++) if (mouse_x >= col_left[i] && mouse_x <= col_left[i] + col_width[i]) { kx = i; break; } int ky = -1; for (i = 0; i < row_count - 1; i++) if (mouse_y >= row_top[i] && mouse_y <= row_top[i] + row_height[i]) { ky = i; break; } if (kx != -1 && ky != -1) { if (!shift) { move_sel(kx, ky); //return; } else { sel_end_x = kx; sel_end_y = ky; } size_state = SIZE_SELECT; } } if (size_state) { size_mouse_x = mouse_x; size_mouse_y = mouse_y; } return; } else if (!mouse_btn && size_state) { sel_moved = 0; // чтобы была тру перерисовка //rtlDebugOutString("resize end"); if (size_state == SIZE_DRAG) { fill_cells(sel_x, sel_y, sel_end_x, sel_end_y, old_end_x, old_end_y); } //sel_moved = (size_state == SIZE_SELECT && sel_x == sel_end_x && sel_y == sel_end_y && was_single_selection); size_state = 0; draw_window(); // все сдвинулось - надо обновиться return; } if (size_state == SIZE_X && mouse_x != size_mouse_x) { draw_size_grid(); col_width[size_id] += mouse_x - size_mouse_x; if (col_width[size_id] < 15) col_width[size_id] = 15; else if (col_width[size_id] > wi / 2) col_width[size_id] = wi / 2; draw_size_grid(); } if (size_state == SIZE_Y && mouse_y != size_mouse_y) { draw_size_grid(); row_height[size_id] += mouse_y - size_mouse_y; if (row_height[size_id] < 15) row_height[size_id] = 15; else if (row_height[size_id] > he / 2) row_height[size_id] = he / 2; draw_size_grid(); } if ((size_state == SIZE_SELECT || size_state == SIZE_DRAG) && (mouse_x != size_mouse_x || mouse_y != size_mouse_y)) { draw_drag(); int kx = -1, i; for (i = 0; i < col_count - 1; i++) if (mouse_x >= col_left[i] && mouse_x <= col_left[i + 1]) { //sprintf(debuf, "yyy %U",col_left[i+1]); //rtlDebugOutString(debuf); kx = i; break; } int ky = -1; for (i = 0; i < row_count - 1; i++) if (mouse_y >= row_top[i] && mouse_y <= row_top[i + 1]) { ky = i; break; } if (kx != -1) sel_end_x = kx; if (kx != -1) sel_end_y = ky; if (size_state == SIZE_DRAG) { if (abs(sel_end_x - sel_x) > 0) { sel_end_y = old_end_y; } else if (abs(sel_end_y - sel_y) > 0) { sel_end_x = old_end_x; } } draw_drag(); } size_mouse_x = mouse_x; size_mouse_y = mouse_y; }