void init_marquee(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); marqueestruct *mp; XGCValues gcv; int i; if (marquees == NULL) { if ((marquees = (marqueestruct *) calloc(MI_NUM_SCREENS(mi), sizeof (marqueestruct))) == NULL) return; } mp = &marquees[MI_SCREEN(mi)]; mp->win_width = MI_WIDTH(mi); mp->win_height = MI_HEIGHT(mi); if (MI_NPIXELS(mi) > 2) mp->color = NRAND(MI_NPIXELS(mi)); mp->time = 0; mp->t = 0; mp->nonblanks = 0; mp->x = 0; MI_CLEARWINDOW(mi); if (mode_font == None) mode_font = getFont(display); if (mp->gc == NULL && mode_font != None) { gcv.font = mode_font->fid; gcv.graphics_exposures = False; gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); if ((mp->gc = XCreateGC(display, MI_WINDOW(mi), GCForeground | GCBackground | GCGraphicsExposures | GCFont, &gcv)) == None) { return; } mp->ascent = mode_font->ascent; mp->height = font_height(mode_font); for (i = 0; i < 256; i++) if ((i >= (int) mode_font->min_char_or_byte2) && (i <= (int) mode_font->max_char_or_byte2)) char_width[i] = font_width(mode_font, (char) i); else char_width[i] = font_width(mode_font, (char) mode_font->default_char); } else if (mode_font == None) { for (i = 0; i < 256; i++) char_width[i] = 8; } mp->words = fixup_back(getWords(MI_SCREEN(mi), MI_NUM_SCREENS(mi))); mp->y = 0; if (isRibbon()) { mp->x = mp->win_width; if (mp->win_height > font_height(mode_font)) mp->y += NRAND(mp->win_height - font_height(mode_font)); else if (mp->win_height < font_height(mode_font)) mp->y -= NRAND(font_height(mode_font) - mp->win_height); } else { int text_ht = text_height(mp->words); int text_font_wid = text_font_width(mp->words); if (mp->win_height > text_ht * font_height(mode_font)) mp->y = NRAND(mp->win_height - text_ht * font_height(mode_font)); if (mp->y < 0) mp->y = 0; mp->x = 0; if (mp->win_width > text_font_wid) mp->x += NRAND(mp->win_width - text_font_wid); /* else if (mp->win_width < text_font_wid) mp->x -= NRAND(text_font_wid - mp->win_width); */ mp->startx = mp->x; } }
static void draw_suggestion_list(SpaceText *st, ARegion *ar) { SuggItem *item, *first, *last, *sel; TextLine *tmp; char str[SUGG_LIST_WIDTH+1]; int w, boxw=0, boxh, i, l, x, y, b, *top; if(!st || !st->text) return; if(!texttool_text_is_active(st->text)) return; first = texttool_suggest_first(); last = texttool_suggest_last(); if(!first || !last) return; text_pop_suggest_list(); sel = texttool_suggest_selected(); top = texttool_suggest_top(); /* Count the visible lines to the cursor */ for(tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++); if(l<0) return; if(st->showlinenrs) { x = st->cwidth*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4; } else { x = st->cwidth*(st->text->curc-st->left) + TXT_OFFSET - 4; } y = ar->winy - st->lheight*l - 2; boxw = SUGG_LIST_WIDTH*st->cwidth + 20; boxh = SUGG_LIST_SIZE*st->lheight + 8; UI_ThemeColor(TH_SHADE1); glRecti(x-1, y+1, x+boxw+1, y-boxh-1); UI_ThemeColor(TH_BACK); glRecti(x, y, x+boxw, y-boxh); /* Set the top 'item' of the visible list */ for(i=0, item=first; i<*top && item->next; i++, item=item->next); for(i=0; i<SUGG_LIST_SIZE && item; i++, item=item->next) { y -= st->lheight; strncpy(str, item->name, SUGG_LIST_WIDTH); str[SUGG_LIST_WIDTH] = '\0'; w = text_font_width(st, str); if(item == sel) { UI_ThemeColor(TH_SHADE2); glRecti(x+16, y-3, x+16+w, y+st->lheight-3); } b=1; /* b=1 color block, text is default. b=0 no block, color text */ switch (item->type) { case 'k': UI_ThemeColor(TH_SYNTAX_B); b=0; break; case 'm': UI_ThemeColor(TH_TEXT); break; case 'f': UI_ThemeColor(TH_SYNTAX_L); break; case 'v': UI_ThemeColor(TH_SYNTAX_N); break; case '?': UI_ThemeColor(TH_TEXT); b=0; break; } if(b) { glRecti(x+8, y+2, x+11, y+5); UI_ThemeColor(TH_TEXT); } text_draw(st, str, 0, 0, 1, x+16, y-1, NULL); if(item == last) break; } }