/* * Move the cursor up/down the specified number of lines, scrolling * to a new screen if necessary. */ void upLINE(RING * gbl, unsigned n) { if (gbl->curfile < n) gbl->curfile = 0; else gbl->curfile -= n; if (gbl->curfile < vue->base_file) { unsigned savebase = vue->base_file; while (gbl->curfile < vue->base_file && vue->base_file > 0) { vue->base_file -= 1; setup_view(gbl); } #if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG) if (vue->base_file < savebase && setscrreg((int) vue->base_row + 1, (int) vue->last_row - 1) != ERR) { scrl((int) (vue->base_file - savebase)); setscrreg(0, LINES - 1); } #endif showFILES(gbl, FALSE); } else { showC(gbl); } }
/* * Display all files in the current screen (all viewports), and then show the * remaining stuff on the screen (position in each viewport and workspace * marker). */ void showFILES(RING * gbl, int reset_cols) { unsigned current = curview; int j; unsigned k; TRACE(("showFILES(%s,%d)\n", gbl->new_wd, reset_cols)); if (reset_cols) for (j = 0; j < CCOL_MAX; j++) gbl->cmdcol[j] = 0; save_view(gbl); for (k = 0; k < maxview; k++) { show_view(vue->gbl); if (maxview > 1) { if (vue->gbl != viewlist[current].gbl) show_what(vue); next_view(); } } showMARK(gbl->Xbase); clear_work(); showC(gbl); TRACE(("...done showFILES\n")); }
void downLINE(RING * gbl, unsigned n) { gbl->curfile += n; if (gbl->curfile >= gbl->numfiles) gbl->curfile = gbl->numfiles - 1; if (gbl->curfile > vue->last_file) { unsigned savebase = vue->base_file; while (gbl->curfile > vue->last_file && (vue->last_file + 1) < gbl->numfiles) { vue->base_file += 1; setup_view(gbl); } #if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG) if (vue->base_file > savebase && setscrreg((int) vue->base_row + 1, (int) vue->last_row - 1) != ERR) { scrl((int) (vue->base_file - savebase)); setscrreg(0, LINES - 1); } #endif showFILES(gbl, FALSE); } else showC(gbl); }
void scroll_to_file(RING * gbl, unsigned inx) { if (gbl->curfile != inx) { gbl->curfile = inx; if (to_file(gbl)) showFILES(gbl, FALSE); else showC(gbl); } }
void restat_W(RING * gbl) { int j; int Ylast = lastVIEW(); for (j = (int) baseVIEW(); j <= Ylast; j++) { statLINE(gbl, (unsigned) j); showLINE(gbl, (unsigned) j); } showC(gbl); }
/* * Move cursor to the "other" view. */ RING * tab2VIEW(RING * gbl) { save_view(gbl); if (maxview > 1) { next_view(); if (ring_view()) showC(vue->gbl); showMARK(vue->gbl->Xbase); } else dedmsg(gbl, "no other viewport"); return vue->gbl; }
int showDOWN(RING * gbl) { showLINE(gbl, gbl->curfile); dlog_name(cNAME); if ((gbl->curfile + 1) < gbl->numfiles) { downLINE(gbl, 1); } else { showC(gbl); return (FALSE); } return (TRUE); }
/* * Prompt user for yes/no response */ int user_says(RING * gbl, int ok) { char *s; static DYN *reply; if (!ok) { dyn_init(&reply, 8); if ((s = dlog_string(gbl, "Are you sure (y/n)? ", -1, &reply, (DYN **) 0, NO_HISTORY, EOS, -8)) != NULL) ok = (*s == 'y' || *s == 'Y'); showC(gbl); } return (ok); }
/* * re-'stat()' the current line, and optionally group */ void restat(RING * gbl, int group) { if (group) { unsigned j; for_each_file(gbl, j) { if (j != gbl->curfile) { if (gFLAG(j)) { statLINE(gbl, j); showLINE(gbl, j); } } } } statLINE(gbl, gbl->curfile); showLINE(gbl, gbl->curfile); showC(gbl); }
RING * row2VIEW(RING * gbl, int row) { VIEW *vp; unsigned n, nn; for (n = 0; n < maxview; n++) { vp = viewlist + n; nn = ROW2FILE(vp, (unsigned) row); if (FILE_VISIBLE(vp, nn)) { curview = n; vp->curfile = nn; init_view(); gbl = vue->gbl; showC(gbl); break; } } return gbl; }
Menu::Menu(QWidget *parent) : defaultScreenWidth(480), defaultScreenHeight(800), QMainWindow(parent) { setAttribute(Qt::WA_DeleteOnClose); central = new QWidget(this); central->setObjectName("central"); windowTitle = new QLabel; windowTitle->setScaledContents(true); AButton = new QPushButton(tr("Сложение")); AButton->setFocusPolicy(Qt::NoFocus); connect(AButton, SIGNAL(clicked()), this, SLOT(showA())); BButton = new QPushButton(tr("Вычитание")); BButton->setFocusPolicy(Qt::NoFocus); connect(BButton, SIGNAL(clicked()), this, SLOT(showB())); CButton = new QPushButton(tr("Умножение на число")); CButton->setFocusPolicy(Qt::NoFocus); connect(CButton, SIGNAL(clicked()), this, SLOT(showC())); DButton = new QPushButton(tr("Умножение")); DButton->setFocusPolicy(Qt::NoFocus); connect(DButton, SIGNAL(clicked()), this, SLOT(showD())); EButton = new QPushButton(tr("Транспонирование")); EButton->setFocusPolicy(Qt::NoFocus); connect(EButton, SIGNAL(clicked()), this, SLOT(showE())); FButton = new QPushButton(tr("Определитель")); FButton->setFocusPolicy(Qt::NoFocus); connect(FButton, SIGNAL(clicked()), this, SLOT(showF())); GButton = new QPushButton(tr("Возведение в степень")); GButton->setFocusPolicy(Qt::NoFocus); connect(GButton, SIGNAL(clicked()), this, SLOT(showG())); HButton = new QPushButton(tr("Обратная матрица")); HButton->setFocusPolicy(Qt::NoFocus); connect(HButton, SIGNAL(clicked()), this, SLOT(showH())); IButton = new QPushButton(tr("След")); IButton->setFocusPolicy(Qt::NoFocus); connect(IButton, SIGNAL(clicked()), this, SLOT(showI())); JButton = new QPushButton(tr("Треугольный вид")); JButton->setFocusPolicy(Qt::NoFocus); connect(JButton, SIGNAL(clicked()), this, SLOT(showJ())); KButton = new QPushButton(tr("Ранг")); KButton->setFocusPolicy(Qt::NoFocus); connect(KButton, SIGNAL(clicked()), this, SLOT(showK())); LButton = new QPushButton(tr("Определенность матрицы")); LButton->setFocusPolicy(Qt::NoFocus); connect(LButton, SIGNAL(clicked()), this, SLOT(showL())); settingsButton = new QPushButton(tr("Настройки")); settingsButton->setFocusPolicy(Qt::NoFocus); connect(settingsButton, SIGNAL(clicked()), this, SLOT(showSettings())); scaling(); designInit(); sizeInit(); init(); setCentralWidget(central); setWindowTitle(tr("Матричный калькулятор++")); }
void dedtype(RING * gbl, char *name, int inlist, int binary, int stripped, int isdir) { int had_eof; int c; int count, /* ...and repeat-count */ y, /* current line-in-screen */ shift = COLS / 4, /* amount of left/right shift */ done = FALSE, shown = FALSE, infile = -1; /* # of lines processed */ OFF_T skip = 0; tabstop = 8; Shift = 0; UsePattern = FALSE; OptBinary = binary; OptStripped = stripped; if (isdir && !OptBinary) { DIR *dp; DirentT *de; char bfr[MAXPATHLEN]; # define INO_FMT "%5lu" if ((InFile = tmpfile()) == 0) { warn(gbl, "tmp-file"); return; } if ((dp = opendir(name)) != 0) { while ((de = readdir(dp)) != NULL) { (void) ded2string(gbl, bfr, (int) NAMLEN(de), de->d_name, FALSE); FPRINTF(InFile, INO_FMT, (unsigned long) de->d_ino); FPRINTF(InFile, " %s\n", bfr); } (void) closedir(dp); rewind(InFile); } else { warn(gbl, "opendir"); FCLOSE(InFile); return; } } else InFile = fopen(name, "r"); in_dedtype = TRUE; /* disable clearing of workspace via A/a cmd */ if (InFile) { int jump = 0; dlog_comment("type \"%s\" (%s %s)\n", name, OptBinary ? "binary" : "text", isdir ? "directory" : "file"); to_work(gbl, FALSE); dyn_init(&my_text, BUFSIZ); dyn_init(&my_over, BUFSIZ); max_lines = -1; MarkLine(&infile); while (!done) { if (jump) { #if defined(HAVE_WSCRL) && defined(HAVE_WSETSCRREG) /* * If we're doing single-line scrolling past * the point we've read in the file, try to * cache pointers so that the scrolling logic * will go more smoothly. */ if (jump > 0 && jump < NumP(1) && infile + NumP(1) >= max_lines) { int line = infile; (void) StartPage(&line, TRUE, &had_eof); } #endif (void) JumpBackwards(&infile, jump); jump = 0; } markC(gbl, TRUE); y = StartPage(&infile, (int) skip, &had_eof); if (skip && !was_interrupted) { if (feof(InFile)) { skip = 0; jump = NumP(1); } else { IgnorePage(infile); skip--; } continue; } if (had_eof) { int blank; infile = TopOfPage(infile, &blank); (void) JumpToLine(infile); y = StartPage(&infile, 0, &had_eof); } shown |= FinishPage(gbl, inlist, infile, y); jump = NumP(1); reset_catcher(); switch (c = dlog_char(gbl, &count, 1)) { case CTL('K'): deddump(gbl); break; case 'w': retouch(gbl, 0); break; case '\t': if (OptBinary) { beep(); } else { tabstop = (count <= 1) ? (tabstop == 8 ? 4 : 8) : count; } break; case 'q': done = TRUE; break; case KEY_HOME: case '^': jump = infile; break; case KEY_END: case '$': infile = max_lines; skip = MaxP(); break; case KEY_PPAGE: case '\b': case 'b': if (AtTop(infile)) { beep(); } else { jump += NumP(count); } break; case KEY_NPAGE: case '\n': case ' ': case 'f': jump = 0; skip = count - 1; break; case '<': case CTL('L'): LeftOrRight(-shift * count); break; case '>': case CTL('R'): LeftOrRight(shift * count); break; case KEY_LEFT: case 'h': LeftOrRight(-count); break; case KEY_DOWN: case 'j': jump = NumP(1) - count; if ((infile - jump) > max_lines) { skip = (-jump + NumP(1) - 1) / NumP(1); jump = 0; } break; case KEY_UP: case 'k': if (AtTop(infile)) { beep(); } else { jump += count; } break; case KEY_RIGHT: case 'l': LeftOrRight(count); break; /* move work-area marker */ case 'A': count = -count; jump -= count; /*FALLTHRU */ case 'a': markset(gbl, (unsigned) (mark_W + count)); break; case '/': case '?': case 'n': case 'N': FindPattern(gbl, &infile, c); break; default: beep(); } } FCLOSE(InFile); if (shown) (void) reshow(gbl, (unsigned) inlist); showMARK(gbl->Xbase); showC(gbl); } else warn(gbl, name); in_dedtype = FALSE; }
static void FindPattern(RING * gbl, int *infile, int key) { int foo; char *s; int next, save = *infile; static DYN *text; static HIST *History; static int order; /* saves last legal search order */ static int ok_expr; if (key == '/' || key == '?') { dyn_init(&text, BUFSIZ); if (!(s = dlog_string(gbl, "Target: ", LINES - 1, &text, (DYN **) 0, &History, EOS, BUFSIZ)) || !*s) { UsePattern = FALSE; return; } if (key == '/') order = 1; if (key == '?') order = -1; next = order; } else if (order && (s = dyn_string(text))) { next = (key == 'n') ? order : -order; } else { waitmsg("No previous regular expression"); return; } if (ok_expr) OLD_REGEX(ToFind); if ((ok_expr = NEW_REGEX(ToFind, s)) != 0) { UsePattern = TRUE; if (SamePattern(s)) { if (ispunct(key)) return; } else { if (next < 0) ; else if (JumpBackwards(infile, NumP(1)) < 0) return; } if (next < 0) { while (JumpBackwards(infile, NumP(2)) >= 0) { if (FoundPattern(infile)) return; } } else { while (!feof(InFile)) { if (FoundPattern(infile)) return; } } *infile = TopOfPage(save, &foo); if (JumpToLine(*infile) >= 0) (void) StartPage(infile, FALSE, &foo); waitmsg("Expression not found"); } else { order = 0; UsePattern = FALSE; BAD_REGEX(ToFind); showC(gbl); } }