void Font::draw_text(Renderer *renderer, const std::string& text, const Vector& pos, DrawingEffect drawing_effect, Color color, float alpha) const { if(shadowsize > 0) draw_chars(renderer, false, text, pos + Vector(shadowsize, shadowsize), drawing_effect, Color(1,1,1), alpha); draw_chars(renderer, true, text, pos, drawing_effect, color, alpha); }
bool draw_lineno(struct view *view, unsigned int lineno) { char number[10]; int digits3 = view->digits < 3 ? 3 : view->digits; int max = MIN(VIEW_MAX_LEN(view), digits3); char *text = NULL; chtype separator = opt_line_graphics ? ACS_VLINE : '|'; if (!opt_show_line_numbers) return FALSE; lineno += view->pos.offset + 1; if (lineno == 1 || (lineno % opt_line_number_interval) == 0) { static char fmt[] = "%1ld"; fmt[1] = '0' + (view->digits <= 9 ? digits3 : 1); if (string_format(number, fmt, lineno)) text = number; } if (text) draw_chars(view, LINE_LINE_NUMBER, text, max, TRUE); else draw_space(view, LINE_LINE_NUMBER, max, digits3); return draw_graphic(view, LINE_DEFAULT, &separator, 1, TRUE); }
static bool draw_lineno_custom(struct view *view, struct view_column *column, unsigned int lineno) { char number[10]; unsigned long digits3 = column->width < 3 ? 3 : column->width; int max = MIN(VIEW_MAX_LEN(view), digits3); char *text = NULL; chtype separator = opt_line_graphics ? ACS_VLINE : '|'; struct line_number_options *opts = &column->opt.line_number; int interval = opts->interval > 0 ? opts->interval : 5; if (!column->opt.line_number.display) return false; if (lineno == 1 || (lineno % interval) == 0) { static char fmt[] = "%ld"; fmt[1] = '0' + (digits3 <= 9 ? digits3 : 1); if (string_format(number, fmt, lineno)) text = number; } if (text) draw_chars(view, LINE_LINE_NUMBER, text, -1, max, true); else draw_space(view, LINE_LINE_NUMBER, max, digits3); return draw_graphic(view, LINE_DEFAULT, &separator, 1, true); }
static void draw_line(VGFT_FONT_T *font, VGfloat x, VGfloat y, const char *text, int char_count, VGbitfield paint_modes) { if (char_count == 0) return; // Set origin to requested x,y VGfloat glor[] = { x, y }; vgSetfv(VG_GLYPH_ORIGIN, 2, glor); // Draw the characters in blocks to reuse buffer memory const char *curr_text = text; int chars_left = char_count; while (chars_left > CHAR_COUNT_MAX) { draw_chars(font, curr_text, CHAR_COUNT_MAX, paint_modes, 1); chars_left -= CHAR_COUNT_MAX; curr_text += CHAR_COUNT_MAX; } // Draw the last block draw_chars(font, curr_text, chars_left, paint_modes, 0); }
static bool draw_text_expanded(struct view *view, enum line_type type, const char *string, int max_len, bool use_tilde) { static char text[SIZEOF_STR]; do { size_t pos = string_expand(text, sizeof(text), string, opt_tab_size); if (draw_chars(view, type, text, max_len, use_tilde)) return TRUE; string += pos; } while (*string); return VIEW_MAX_LEN(view) <= 0; }
static bool draw_space(struct view *view, enum line_type type, int max, int spaces) { static char space[] = " "; spaces = MIN(max, spaces); while (spaces > 0) { int len = MIN(spaces, sizeof(space) - 1); if (draw_chars(view, type, space, len, FALSE)) return TRUE; spaces -= len; } return VIEW_MAX_LEN(view) <= 0; }
static bool draw_text_expanded(struct view *view, enum line_type type, const char *string, int length, int max_width, bool use_tilde) { static char text[SIZEOF_STR]; if (length == -1) length = strlen(string); do { size_t pos = string_expand(text, sizeof(text), string, length, opt_tab_size); if (draw_chars(view, type, text, -1, max_width, use_tilde)) return true; string += pos; length -= pos; } while (*string && length > 0); return VIEW_MAX_LEN(view) <= 0; }
bool draw_field(struct view *view, enum line_type type, const char *text, int width, enum align align, bool trim) { int max = MIN(VIEW_MAX_LEN(view), width + 1); int col = view->col; if (!text) return draw_space(view, type, max, max); if (align == ALIGN_RIGHT) { int textlen = strlen(text); int leftpad = max - textlen - 1; if (leftpad > 0) { if (draw_space(view, type, leftpad, leftpad)) return TRUE; max -= leftpad; col += leftpad;; } } return draw_chars(view, type, text, max - 1, trim) || draw_space(view, LINE_DEFAULT, max - (view->col - col), max); }
/*######################### draw_line_status() ##########################*/ void draw_line_status(int pos, signed char delta) { int column, x, y; char line[MAX_COLUMN_LENGTH + 1]; /* First locate position of x and y. */ locate_xy_column(pos, &x, &y, &column); #ifdef _DEBUG (void)printf("Drawing line %d %d x = %d y = %d\n", pos, counter++, x, y); #endif if ((connect_data[pos].inverse > OFF) && (delta >= 0)) { if (connect_data[pos].inverse == ON) { attrset(COLOR_PAIR(NORMAL_BG)); } else { attrset(COLOR_PAIR(LOCKED_BG)); } } else { attrset(COLOR_PAIR(DEFAULT_BG)); } memset(line, ' ', line_length[column]); line[line_length[column]] = '\0'; mvaddstr(y, x, line); /* Write destination identifier to screen. */ draw_dest_identifier(pos, x, y); if (line_style & SHOW_LEDS) { /* Draw debug led. */ draw_debug_led(pos, x, y); /* Draw status LED's. */ draw_led(pos, 0, x, y); draw_led(pos, 1, x + 1 + LED_SPACING, y); } if (line_style & SHOW_JOBS) { int i; /* Draw status button for each parallel transfer. */ for (i = 0; i < fsa[pos].allowed_transfers; i++) { draw_proc_stat(pos, i, x, y); } } /* Print information for number of files to be send (nf), */ /* total file size (tfs), transfer rate (tr) and error */ /* counter (ec). */ if (line_style & SHOW_CHARACTERS) { draw_chars(pos, NO_OF_FILES, x, y, column); draw_chars(pos, TOTAL_FILE_SIZE, x + (5 * glyph_width), y, column); draw_chars(pos, TRANSFER_RATE, x + (10 * glyph_width), y, column); draw_chars(pos, ERROR_COUNTER, x + (15 * glyph_width), y, column); } return; }
static int find_cache_item(unsigned rec_num,int assign_uncompressed) {int i=cache_head,d=get_current_db_idx(),idle_item=(cache_head+1)&cache_length_mask; if(assign_uncompressed)uncompressed=0; if(saved_uncompressed&&cache[idle_item].chunk.d>=0 &&saved_uncompressed==cache[idle_item].content) idle_item=(idle_item+1)&cache_length_mask; if(facunde) {char s[0x33];StrCopy(s,"cache find ");StrCat(s,"("); StrIToA(s+StrLen(s),d);StrCat(s,":"); StrIToA(s+StrLen(s),rec_num);StrCat(s,")"); draw_chars(s,0,0); } do {if(facunde) {char s[0x33];StrCopy(s,"cache ");StrIToA(s+StrLen(s),i);StrCat(s,":("); StrIToA(s+StrLen(s),cache[i].db_idx);StrCat(s,":"); StrIToA(s+StrLen(s),cache[i].rec_num);StrCat(s,");"); StrIToA(s+StrLen(s),cache[i].chunk.d);StrCat(s," "); draw_chars(s,0,0); } if(cache[i].chunk.d<0){idle_item=i;goto next_i;} if(d==cache[i].db_idx&&rec_num==cache[i].rec_num) {if(facunde) {char s[0x33];StrCopy(s,"found ");StrCat(s," "); StrIToA(s+StrLen(s),i);StrCat(s,":("); StrIToA(s+StrLen(s),d);StrCat(s,":"); StrIToA(s+StrLen(s),rec_num);StrCat(s,")"); StrIToH(s+StrLen(s),(UInt32)(cache[i].content));StrCat(s," "); draw_chars(s,0,0); }if(assign_uncompressed)uncompressed=cache[i].content;return i; } next_i:i=(i-1)&cache_length_mask; }while(i!=cache_head); if(facunde) {char s[0x33];StrCopy(s,"cache loop done ");StrIToA(s+StrLen(s),idle_item);StrCat(s,":("); StrIToA(s+StrLen(s),cache[idle_item].db_idx);StrCat(s,":"); StrIToA(s+StrLen(s),cache[idle_item].rec_num);StrCat(s,");"); StrIToA(s+StrLen(s),cache[idle_item].chunk.d);StrCat(s," "); draw_chars(s,0,0); } if(cache[idle_item].chunk.d>=0) {free_chunk(cache[idle_item].chunk); cache[idle_item].chunk.d=invalid_chunk_descriptor; }i=(idle_item+1)&cache_length_mask; while(i!=idle_item) {cache[idle_item].chunk=alloc_chunk(dh.record_size); if(cache[idle_item].chunk.d>=0){cache_head=idle_item;break;} while(i!=idle_item) {int i_prev=i;i=(i+1)&cache_length_mask; if(cache[i_prev].chunk.d>=0&& (!saved_uncompressed||saved_uncompressed!=cache[i_prev].content)) {free_chunk(cache[i_prev].chunk); cache[i_prev].chunk.d=invalid_chunk_descriptor;break; } } } if(facunde) {char s[0x33];StrCopy(s,"idle alloc ");StrIToA(s+StrLen(s),idle_item);StrCat(s,":("); StrIToA(s+StrLen(s),d);StrCat(s,":"); StrIToA(s+StrLen(s),rec_num);StrCat(s,");"); StrIToA(s+StrLen(s),cache[idle_item].chunk.d);StrCat(s," "); draw_chars(s,0,0); } if(cache[idle_item].chunk.d>=0) {if(inflate_into_chunk(cache[idle_item].chunk)) {free_chunk(cache[idle_item].chunk); cache[idle_item].chunk.d=invalid_chunk_descriptor; }else {const char*uc=lock_chunk(cache[idle_item].chunk); cache[idle_item].rec_num=rec_num;cache[idle_item].db_idx=d; cache[idle_item].content=uc;if(assign_uncompressed)uncompressed=uc; return idle_item; } }return-1; }