void mfc_term_view::save_line(const char *txt) // to end of hist_view { long mn0, mx0; GetRichEditCtrl().GetSel(mn0, mx0); long i = eob(1); if (mx0 > i) mn0 = mx0 = i; GetRichEditCtrl().SetSel(i, eob(0)); GetRichEditCtrl().ReplaceSel(txt); GetRichEditCtrl().SetSel(mn0, mx0); }
void mfc_term_view::send_or_copy() // bound to Enter in term_view { long i, m; GetRichEditCtrl().GetSel(i, m); m = GetRichEditCtrl().LineIndex(GetRichEditCtrl().LineFromChar(mark)); if (i >= m) { // send new input as command line m = eob(); //if (GetRichEditCtrl().LineLength(m)) { GetRichEditCtrl().SetSel(m, m); GetRichEditCtrl().ReplaceSel("\r\n"); GetRichEditCtrl().GetSel(i, m); //} GetRichEditCtrl().SetSel(mark, m); CString txt = GetRichEditCtrl().GetSelText(); if (mfc_deliver(txt, txt.GetLength())) { hist_view->save_line(txt); mark = m; } GetRichEditCtrl().SetSel(m, m); } else { // copy current line as pending new command line CString txt = grab_line(); set_command(w_deprompt((char *)(const char *)txt)); } }
int mfc_term_view::at_eob() { long mn, mx; GetRichEditCtrl().GetSel(mn, mx); return (mn==mx && mx==eob()); }
void mfc_term_view::set_command(const char *txt) // at end of term_view { GetRichEditCtrl().SetSel(mark, eob(0)); GetRichEditCtrl().ReplaceSel(txt); long mn, mx; GetRichEditCtrl().GetSel(mn, mx); GetRichEditCtrl().SetSel(mx, mx); }
void test_page_read_with_offset ( const char *fname ) { put_msg (INFO, "test_page_read_with_offset() ...\n"); pager_init (); /* put_pager_info (DEBUG, "After pager_init"); */ page_p pg; int int_out; char str_out[14]; int bnr; for (bnr = 0; bnr < NUM_BLOCKS_IN_FILE; bnr++) { pg = get_page ( fname, bnr ); if ( pg == NULL) { put_msg (FATAL, "get_page %d fails\n", bnr); put_pager_info (FATAL, "After get_page"); exit (EXIT_FAILURE); } /* put_pager_info (DEBUG, "After get_page"); */ int i = 0; while (!eob(pg)) { int offset = PAGE_HEADER_SIZE + i*(INT_SIZE + str_len); int_out = page_get_int_at(pg, offset); if ( int_out != ints_in[i] + bnr ) { put_msg (FATAL, "test_page_read fails: (read: %d, should be %d)\n", int_out, ints_in[i] + bnr); put_pager_info (FATAL, "After page_get_int_at"); exit (EXIT_FAILURE); } offset += INT_SIZE; page_get_str_at (pg, offset, str_out, str_len); if ( strcmp (str_out, strs_in[i]) != 0 ) { put_msg (FATAL, "test_page_read fails: (read: \"%s\", should be \"%s\")\n", str_out, strs_in[i] + bnr); put_pager_info (FATAL, "After page_get_str_at"); exit (EXIT_FAILURE); } i++; } unpin (pg); } put_pager_profiler_info (INFO); pager_terminate (); /* put_pager_info (DEBUG, "After pager_terminate"); */ put_msg (INFO, "test_page_read_with_offset() succeeds.\n"); }
void mfc_term_view::on_undo() { /* note: WM_UNDO never sent or never reaches WindowProc * -- neither does ID_EDIT_UNDO WM_COMMAND message?? */ long len0 = eob(); CRichEditView::OnEditUndo(); get_state(); if (smin < mark) mark += len - len0; recalling = 0; }
void mfc_term_view::recall_line() // bound to Enter in hist_view { CString txt = grab_line(); term_view->set_command(txt); long i = bol(0); // get first char of current line if (i == bol(1)) { // this line typed at end: send it term_view->send_or_copy(); i = eob(); } else if (term_view->is_visible) { CMDIFrameWnd *fw = (CMDIFrameWnd *)(the_boss.m_pMainWnd); fw->MDIActivate(term_view->GetParent()); } GetRichEditCtrl().SetSel(i, i); }
z_status zp_parser::_process_template(zp_mode mode) { zp_flags flags; flags.as_u32=0; flags.required=1; z_status s= _process_group(flags,mode); if(s) return s; skip_ws(); if(eob()) return s; return zs_unparsed_data; }
static page_p get_page_for_next_record ( schema_p s ) { page_p pg = s->tbl->current_pg; if (eof(pg)) return NULL; if (eob(pg)) { unpin (pg); pg = get_next_page (pg); if ( pg == NULL) { put_msg (FATAL, "get_page_for_next_record failed at block %d\n", page_block_nr(pg) + 1); exit (EXIT_FAILURE); } page_set_pos_begin (pg); s->tbl->current_pg = pg; } return pg; }
static void skip_chars_forward (char *range, int invert) { SLwchar_Lut_Type *lut; int ignore_combining = 1; if (*range == '^') { invert = !invert; range++; } if (NULL == (lut = SLwchar_strtolut ((SLuchar_Type *)range, 1, 1))) return; do { unsigned char *p = CLine->data + Point; unsigned char *pmax = CLine->data + CLine->len; p = SLwchar_skip_range (lut, p, pmax, ignore_combining, invert); if (p == NULL) { SLwchar_free_lut (lut); return; } if (p < pmax) { jed_position_point (p); SLwchar_free_lut (lut); return; } } while (jed_down (1)); SLwchar_free_lut (lut); eob(); }
void mfc_term_view::get_state() { len = eob(); GetRichEditCtrl().GetSel(smin, smax); }
LRESULT mfc_term_view::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { LRESULT result = 0; int key_unshifted = 0; long len0 = 0; int top = !recursing; if (top) { if (message==WM_DESTROY) top = 0; recursing = 1; } switch (message) { case WM_KEYDOWN: case WM_CHAR: key_unshifted = (GetKeyState(VK_SHIFT)>=0 && GetKeyState(VK_CONTROL)>=0 && GetKeyState(VK_MENU)>=0); if (key_unshifted) { if (wParam == '\r') { if (message == WM_KEYDOWN) { if (this == term_view) send_or_copy(); else recall_line(); } if (top) recursing = 0; return 0; } else if (this==term_view && message==WM_KEYDOWN) { if ((wParam==VK_UP || wParam==VK_DOWN) && at_eob()) { if (wParam == VK_UP) recall_prev(); else recall_next(); recalling = 1; if (top) recursing = 0; return 0; } } } /* drop through */ case WM_CUT: case WM_PASTE: case EM_REPLACESEL: get_state(); result = CRichEditView::WindowProc(message, wParam, lParam); if (smin<mark || (message==WM_KEYDOWN && wParam=='\b' && smin==smax && smin==mark)) { if (smax > mark) mark = smax; mark += eob() - len; } if (this==term_view && message==WM_KEYDOWN && wParam==VK_HOME) home_mark(); recalling = 0; break; default: if (top && recalling) get_state(); result = CRichEditView::WindowProc(message, wParam, lParam); if (top && recalling) { long smin0=smin, smax0=smax, len0=len; get_state(); recalling = (smin0==smin && smax0==smax && len0==len); } } if (top) recursing = 0; return result; }
Seq * lit_full(const char* nameL, size_t sizeL) { return seq(bob(), lit(reinterpret_cast<const uchar*>(nameL), sizeL), eob()); }