int check(char *tetri) { int i; int j; int *tab; int count; tab = malloc(sizeof(int) * 4); newtab(tab); j = 0; count = 0; i = 0; while (j < 20) { if (tetri[j] == '#' && i <= 3) tab[i++] = counttetri(tetri, j); else if (tetri[j] == '#' && i > 3) j = 53; else if (tetri[j] == '\n') count++; else if (tetri[j] != '.') j = 53; j++; } if (j > 53 || !checkline(tetri, tab)) return (0); return (1); }
/* Create a new table. ** ** IMPORTANT NOTE: The API differs from lua_createtable()! ** ** The array size is non-inclusive. E.g. asize=128 creates array slots ** for 0..127, but not for 128. If you need slots 1..128, pass asize=129 ** (slot 0 is wasted in this case). ** ** The hash size is given in hash bits. hbits=0 means no hash part. ** hbits=1 creates 2 hash slots, hbits=2 creates 4 hash slots and so on. */ GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits) { GCtab *t = newtab(L, asize, hbits); clearapart(t); if (t->hmask > 0) clearhpart(t); return t; }
static void dosearch(Fl_Widget *w, void *) { const inputplace * const i = (inputplace *) w; const char * const val = i->value(); if (strlen(val) < 2 || allspace(val)) return; char *first = strdup(i->value()); char *ptr = first; for (; *ptr; ptr++) { if (*ptr == ' ') *ptr = '+'; } ptr = wk_urlencode(first); free(first); switch (g->tabs[g->curtab].engine) { case TSE_DDG: asprintf(&first, "https://duckduckgo.com/html?q=%s", ptr); break; case TSE_GOOGLE: asprintf(&first, "https://google.com/search?q=%s", ptr); break; case TSE_COUNT: die("Search engine corruption\n"); } free(ptr); free((char *) g->tabs[g->curtab].search); g->tabs[g->curtab].search = strdup(i->value()); if (i->shift && !i->ctrl) { // new tab newtab(first); } else if (i->shift && i->ctrl) { // bg tab newtabbg(first); } else { g->tabs[g->curtab].state = TS_WEB; g->tabs[g->curtab].web->load(first); g->tabs[g->curtab].web->take_focus(); } free(first); }
int opt_env(int *i, char ***env, char **args) { if (!ft_strcmp(args[*i], "-i")) *env = newtab(); else if (!ft_strcmp(args[*i], "-u")) { if (args[*i + 1] && args[*i + 1][0] != '-') { ft_unsetenv(env, args[*i + 1], NULL); (*i)++; } } else { ft_putendl("Illegal option. please use -i or -u"); return (0); } return (1); }
tab::tab(QWidget *parent) : QWidget(parent) { QVBoxLayout * layout = new QVBoxLayout(this); locationbar = new QLineEdit(); searchbar = new QLineEdit(); searchbar->setFixedWidth(300); toparea = new QWidget(); QHBoxLayout * toplayout = new QHBoxLayout(toparea); toplayout->addWidget(locationbar); toplayout->addWidget(searchbar); layout->addWidget(toparea); view = new webview(this); layout->addWidget(view); QObject::connect(locationbar , SIGNAL(returnPressed()) , this , SLOT(loadadress())); QObject::connect(searchbar , SIGNAL(returnPressed()) , this , SLOT(search())); QObject::connect(view ,SIGNAL(urlChanged(QUrl)) , this , SLOT(updatelocation(QUrl))); QObject::connect(view , SIGNAL(linkinnewtab(QString)) , parent , SLOT(newtab(QString))); }
static void dogo(Fl_Widget *w, void *) { inputplace * const i = (inputplace *) w; const char * const val = i->value(); if (strlen(val) < 2 || allspace(val)) { g->url->url->hidewin(); return; } // We need to differentiate between changed and enter-pressed states. if (i->changed()) { urlResults(); if (g->url->url->list->size()) { g->url->url->popup(); } else { g->url->url->hidewin(); } return; } if (g->url->url->win->shown()) { g->url->url->win->hide(); g->w->redraw(); } if (!strncmp(val, "javascript:", 11) && g->tabs[g->curtab].state == TS_WEB) { g->tabs[g->curtab].web->executeJS(val + 11); return; } if (i->shift && !i->ctrl) { // new tab newtab(val); } else if (i->shift && i->ctrl) { // bg tab newtabbg(val); } else { g->tabs[g->curtab].state = TS_WEB; g->tabs[g->curtab].web->load(val); g->tabs[g->curtab].web->take_focus(); } }
void closetab() { if (g->tabs.size() == 1) { if (g->tabs[0].state == TS_WEB) { saveurlbar(); g->closedtabs.push_back(g->tabs[0]); g->tabs[0].web->hide(); } else { if (g->tabs[0].web) { g->tabs[0].web->parent()->remove(g->tabs[0].web); delete g->tabs[0].web; delete g->tabs[0].errors; } } g->tabs.clear(); newtab(); } else { const vector<u16> &order = taborder(); u16 next = order[1]; if (next >= g->curtab) next--; if (g->tabs[g->curtab].state == TS_WEB) { saveurlbar(); g->closedtabs.push_back(g->tabs[g->curtab]); g->tabs[g->curtab].web->hide(); } else { if (g->tabs[g->curtab].web) { g->tabs[g->curtab].web->parent()->remove(g->tabs[g->curtab].web); delete g->tabs[g->curtab].web; delete g->tabs[g->curtab].errors; } } g->tabs.erase(g->tabs.begin() + g->curtab); g->curtab = next; activatetab(g->curtab); } }
void alreadyintb3(t_data *data, char **tabb) { freetab(data->builttab); data->builttab = newtab(tabb); freetab(tabb); }
int tabbar::handle(const int e) { bool ontab = false; u32 which = 0; bool leftcloser = false; // Over a tab? if (mousein) { u32 max; const u32 tabw = calctabw(&max, w()); if (mousex < x() + max * tabw && mousex >= (u32) x()) { ontab = true; u32 tmp = mousex - x(); const u32 whichmod = tmp % tabw; if (whichmod < tabw / 2) leftcloser = true; tmp /= tabw; which = tmp; } } switch (e) { case FL_ENTER: mousein = true; return 1; case FL_LEAVE: mousein = false; redraw(); return 1; case FL_DRAG: if (!dragging && ontab && Fl::event_state(FL_BUTTON1)) { srctab = which; if (abs(Fl::event_x() - (int) dragstartx) >= 10) dragging = true; } // Fallthrough case FL_MOVE: mousex = Fl::event_x(); redraw(); if (ontab) { if (!tooltip() || strcmp(tooltip(), g->tabs[which].title())) { copy_tooltip(g->tabs[which].title()); Fl_Tooltip::enter(0); Fl_Tooltip::enter(this); } } else { if (!tooltip() || strcmp(tooltip(), "")) { tooltip(""); Fl_Tooltip::enter(0); Fl_Tooltip::enter(this); } } return 1; case FL_PUSH: // Double click on empty? if (Fl::event_clicks() && Fl::event_button() == FL_LEFT_MOUSE && !ontab) { newtab(); return 1; } dragstartx = Fl::event_x(); return 1; case FL_RELEASE: // Tiny differences are mouse jerks, ignore under 10 pixels if (abs(Fl::event_x() - (int) dragstartx) < 10) dragging = false; if (dragging) { const tab tmp = g->tabs[srctab]; if (ontab) { u32 newpos = which; // No drag? if ((srctab == newpos - 1 && leftcloser) || (srctab == newpos + 1 && !leftcloser) || srctab == which) goto dragdone; if (!leftcloser && newpos < srctab) newpos++; else if (leftcloser && newpos > srctab) newpos--; g->tabs.erase(g->tabs.begin() + srctab); if (newpos < g->tabs.size()) g->tabs.insert(g->tabs.begin() + newpos, tmp); else g->tabs.push_back(tmp); if (g->curtab == srctab) g->curtab = newpos; else if (g->curtab > srctab && g->curtab <= newpos) g->curtab--; else if (g->curtab < srctab && g->curtab >= newpos) g->curtab++; if (g->curtab >= g->tabs.size()) g->curtab = g->tabs.size() - 1; } else { g->tabs.erase(g->tabs.begin() + srctab); g->tabs.push_back(tmp); if (g->curtab > srctab) g->curtab--; else if (g->curtab == srctab) g->curtab = g->tabs.size() - 1; } } else if (ontab) { if (Fl::event_button() == FL_LEFT_MOUSE) { activatetab(which); } else if (Fl::event_button() == FL_MIDDLE_MOUSE) { activatetab(which); closetab(); } } dragdone: dragging = false; return 1; } return Fl_Widget::handle(e); }