std::vector<std::string> Conf_line::split(std::string const &str) { std::vector<std::string> vec; size_t first = 0; size_t length = 0; while (find_next_word(str, first, length)) { vec.push_back(str.substr(first, length)); first += length; } return vec; }
static void cmd_meta_d(key_info_t key_info, keys_info_t *keys_info) { int old_i, old_c; old_i = input_stat.index; old_c = input_stat.curs_pos; find_next_word(); if(input_stat.index == old_i) { return; } wcsdel(input_stat.line, old_i + 1, input_stat.index - old_i); input_stat.len -= input_stat.index - old_i; input_stat.index = old_i; input_stat.curs_pos = old_c; update_cmdline_text(); }
static void layout_flow(fz_context *ctx, fz_html *box, fz_html *top, float em, float page_h) { fz_html_flow *node, *line_start, *word_start, *word_end, *line_end; float glue_w; float word_w; float line_w; float indent; float avail, line_h; float baseline; int align; em = fz_from_css_number(box->style.font_size, em, em); indent = box->is_first_flow ? fz_from_css_number(top->style.text_indent, em, top->w) : 0; align = top->style.text_align; box->x = top->x; box->y = top->y + top->h; box->w = top->w; box->h = 0; if (!box->flow_head) return; for (node = box->flow_head; node; node = node->next) if (node->type == FLOW_IMAGE) measure_image(ctx, node, top->w, page_h); else measure_word(ctx, node, em); line_start = find_next_word(box->flow_head, &glue_w); line_end = NULL; line_w = indent; word_w = 0; word_start = line_start; while (word_start) { word_end = find_next_glue(word_start, &word_w); if (line_w + word_w <= top->w) { line_w += word_w; glue_w = 0; line_end = word_end; word_start = find_next_word(word_end, &glue_w); word_w = glue_w; } else { avail = page_h - fmodf(box->y + box->h, page_h); line_h = measure_line(line_start, line_end, &baseline); if (line_h > avail) box->h += avail; layout_line(ctx, indent, top->w, line_w, align, line_start, line_end, box, baseline); box->h += line_h; word_start = find_next_word(line_end, &glue_w); line_start = word_start; line_end = NULL; indent = 0; line_w = 0; word_w = 0; } } /* don't justify the last line of a paragraph */ if (align == TA_JUSTIFY) align = TA_LEFT; if (line_start) { avail = page_h - fmodf(box->y + box->h, page_h); line_h = measure_line(line_start, line_end, &baseline); if (line_h > avail) box->h += avail; layout_line(ctx, indent, top->w, line_w, align, line_start, line_end, box, baseline); box->h += line_h; } }
void load_CONFIG(CONFIG *cfg, char *file, int silent) { FILE *fp; char buff[MAX_BUFF_LEN], id[MAX_BUFF_LEN], *buff_ptr; int cfg_ind; if ((*(file) == NULL_CHAR) || ((fp=fopen(file,"r")) == NULL)){ fprintf(stderr,"Warning: Config file %s is unreadable\n",file); return; } while (safe_fgets(buff,MAX_BUFF_LEN,fp) != CNULL) if (!is_comment(buff) && !is_comment_info(buff)){ buff_ptr = buff; strip_newline(buff_ptr); wrdcpy(id,buff_ptr); if ((cfg_ind = is_CONFIG_id(cfg,id)) != NOT_CONFIG_ID){ find_next_word(&buff_ptr); switch (cfg->rec_list[cfg_ind].value_type){ case CFG_TGL: cfg->rec_list[cfg_ind].value = (char *)TOGGLE_ON_CHR; break; case CFG_C: wrdcpy(cfg->rec_list[cfg_ind].value,buff_ptr); break; case CFG_C2:{ char **t_arr; int arg_count = 0; t_arr = (char **)cfg->rec_list[cfg_ind].value; while ((*buff_ptr != NULL_CHAR) && (arg_count < cfg->rec_list[cfg_ind].num_elem)){ wrdcpy(t_arr[arg_count++],buff_ptr); find_next_word(&buff_ptr); } if ((arg_count == cfg->rec_list[cfg_ind].num_elem) && (*buff_ptr != NULL_CHAR)) if (!silent){ fprintf(stderr,"Warning: Ignored Config elements\n"); fprintf(stderr," %s of\n %s\n", buff_ptr,buff); } break; } case CFG_STR: strcpy(cfg->rec_list[cfg_ind].value,buff_ptr); break; default: fprintf(stderr,"Error: Unknown CONFIG type %d\n", cfg->rec_list[cfg_ind].value_type); exit(-1); break; } reset_group(cfg,cfg_ind); } else if (!silent) fprintf(stderr,"Warning: Configuration not usable - %s\n",buff); } fclose(fp); }
static void cmd_meta_f(key_info_t key_info, keys_info_t *keys_info) { find_next_word(); update_cursor(); }