コード例 #1
0
ファイル: markdown.c プロジェクト: nono/upskirt
/* parse_emph2 • parsing single emphase */
static size_t
parse_emph2(struct buf *ob, struct render *rndr, char *data, size_t size, char c)
{
	int (*render_method)(struct buf *ob, struct buf *text, void *opaque);
	size_t i = 0, len;
	struct buf *work = 0;
	int r;

	render_method = (c == '~') ? rndr->make.strikethrough : rndr->make.double_emphasis;

	if (!render_method)
		return 0;
	
	while (i < size) {
		len = find_emph_char(data + i, size - i, c);
		if (!len) return 0;
		i += len;

		if (i + 1 < size && data[i] == c && data[i + 1] == c && i && !isspace(data[i - 1])) {
			work = rndr_newbuf(rndr);
			parse_inline(work, rndr, data, i);
			r = render_method(ob, work, rndr->make.opaque);
			rndr_popbuf(rndr);
			return r ? i + 2 : 0;
		}
		i++;
	}
	return 0;
}
コード例 #2
0
ファイル: gdashboard.c プロジェクト: MartinReidy/goaccess
static void
render_data_line (WINDOW * win, GDashModule * data, int *y, int j,
                  GScroll * gscroll)
{
  GDashRender render;
  GModule module = data->module;
  int expanded = 0, sel = 0, host_bars = 0;
  int x = 0, w, h;

  if (!conf.skip_term_resolver)
    host_bars = 1;

#ifdef HAVE_LIBGEOIP
  host_bars = 1;
#endif

  getmaxyx (win, h, w);
  (void) h;

  if (gscroll->expanded && module == gscroll->current)
    expanded = 1;

  x = DASH_INIT_X;

  if (j >= data->idx_data)
    goto out;

  sel = expanded && j == gscroll->module[module].scroll ? 1 : 0;

  render.win = win;
  render.y = *y;
  render.w = w;
  render.idx = j;
  render.sel = sel;

  render_hits (data, render, &x);
  render_visitors (data, render, &x);
  render_percent (data, render, &x);

  /* render bandwidth if available */
  if (conf.bandwidth)
    render_bandwidth (data, render, &x);

  /* render avgts, cumts and maxts if available */
  if (conf.serve_usecs) {
    render_avgts (data, render, &x);
    render_cumts (data, render, &x);
    render_maxts (data, render, &x);
  }
  /* render request method if available */
  if (conf.append_method)
    render_method (data, render, &x);
  /* render request protocol if available */
  if (conf.append_protocol)
    render_protocol (data, render, &x);
  render_data (data, render, &x);

  /* skip graph bars if module is expanded and we have sub nodes */
  if (module == HOSTS && expanded && host_bars);
  else
    render_bars (data, render, &x);

out:
  (*y)++;
}