[ScrollFg] = 0xFFFFEA, /* Scroll region foreground */
[VerBdr] = 0x99994C, /* Vertical border */
[HorBdr] = 0x000000, /* Horizontal border */
- [Point] = 0xFFFFFF, /* Point background */
+ [Point] = 0xEFEFDA, /* Point background */
[Purple] = 0x6666CC, /* Purple */
[Red] = 0xCC0000, /* Red */
[Orange] = 0xFF7700, /* Orange */
void view_redo(View* view);
void view_paste(View* view, char* str);
void view_putstr(View* view, char* str);
+void view_putraw(View* view, char* str);
char* view_getstr(View* view);
char* view_getcmd(View* view);
char* view_getword(View* view);
{
Row* row = view_getrow(view, i + view->index);
size_t posx = (csr->x + 2), y = (csr->y + 2 + (i * fheight));
- for (size_t i = 0; i < row->len; i++)
+ if (row->off == buf_end(&(view->buffer)))
{
- int rune = row->cols[i].rune;
- if (rune == '\r' || rune == '\n' || rune == '\t')
- rune = ' ';
- if (buf_inpoint(&(view->buffer), row->cols[i].off))
- draw_rect(x, Point, posx, y, row->cols[i].width, fheight);
- if (buf_insel(&(view->buffer), row->cols[i].off))
- draw_rect(x, sel, posx, y, row->cols[i].width, fheight);
- if (row->cols[i].off == view->buffer.selection.end)
- csr_drawn = draw_csr(x, view, fg, fheight, posx, y, csr_drawn);
- if (csrsync && row->cols[i].off == view->buffer.selection.beg)
+ draw_csr(x, view, fg, fheight, posx, y, csr_drawn);
+ break;
+ }
+ else
+ {
+ for (size_t i = 0; i < row->len; i++)
{
- XWarpPointer(x->display, None, x->self, 0, 0, x->width, x->height, posx + row->cols[i].width/2, y + fheight*3/4);
- csrsync = false;
+ int rune = row->cols[i].rune;
+ if (rune == '\r' || rune == '\n' || rune == '\t')
+ rune = ' ';
+ if (buf_inpoint(&(view->buffer), row->cols[i].off))
+ draw_rect(x, Point, posx, y, row->cols[i].width, fheight);
+ if (buf_insel(&(view->buffer), row->cols[i].off))
+ draw_rect(x, sel, posx, y, row->cols[i].width, fheight);
+ if (row->cols[i].off == view->buffer.selection.end)
+ csr_drawn = draw_csr(x, view, fg, fheight, posx, y, csr_drawn);
+ if (csrsync && row->cols[i].off == view->buffer.selection.beg)
+ {
+ XWarpPointer(x->display, None, x->self, 0, 0, x->width, x->height, posx + row->cols[i].width/2, y + fheight*3/4);
+ csrsync = false;
+ }
+ specs = realloc(specs, sizeof(XftGlyphSpec) * ++nspecs);
+ specs[nspecs-1].glyph = XftCharIndex(x->display, font, rune);
+ specs[nspecs-1].x = posx;
+ specs[nspecs-1].y = y + font->ascent;
+ posx += row->cols[i].width;
}
- specs = realloc(specs, sizeof(XftGlyphSpec) * ++nspecs);
- specs[nspecs-1].glyph = XftCharIndex(x->display, font, rune);
- specs[nspecs-1].x = posx;
- specs[nspecs-1].y = y + font->ascent;
- posx += row->cols[i].width;
}
}
x11_draw_glyphs(x, Palette[fg], font, specs, nspecs);
{
buffer[nread] = '\0';
buf_logstart(&pipedata->dest->buffer);
- view_putstr(pipedata->dest, buffer);
+ view_putraw(pipedata->dest, buffer);
}
}
ensure(view_valid(view));
}
+void view_putraw(View* view, char* str)
+{
+ void (*fn)(int) = BUF->oninsert;
+ BUF->oninsert = NULL;
+ buf_puts(BUF, str);
+ BUF->oninsert = fn;
+ ensure(view_valid(view));
+}
+
char* view_getstr(View* view)
{
return buf_gets(BUF);
static void putb(int byte)
{
- if (byte == '\n')
+ if (byte == '\n' && buf_inpoint(&(EditView->buffer), EditView->buffer.selection.end-1))
{
char* str = buf_getsat(&(EditView->buffer), EditView->buffer.point.beg, EditView->buffer.point.end);
EditView->buffer.point.beg = EditView->buffer.point.end;
+ printf("write '%s'\n", str);
writefd(Pty_Fd, str, strlen(str));
free(str);
}
EditView->buffer.point = sel;
/* insert the text */
- EditView->buffer.oninsert = NULL;
- view_putstr(EditView, buffer);
- EditView->buffer.oninsert = putb;
+ view_putraw(EditView, buffer);
/* adjust the original selection and swap it back */
nread = (EditView->buffer.point.end - start);
static void cmd_exec(char* cmd)
{
- if (xpty_active())
+ /* parse the command sigils */
+ char op = '\0', **execcmd = NULL;
+ if (rissigil(*cmd)) op = *(cmd++);
+ execcmd = (op == ':' ? SedCmd : ShellCmd);
+ execcmd[2] = cmd;
+
+ /* get the selection that the command will operate on */
+ if (op && op != '<' && op != '!' && op != '&' && !view_selsize(win_view(EDIT)))
{
- xpty_send(cmd);
+ view_selectall(win_view(EDIT));
}
- else
- {
- /* parse the command sigils */
- char op = '\0', **execcmd = NULL;
- if (rissigil(*cmd)) op = *(cmd++);
- execcmd = (op == ':' ? SedCmd : ShellCmd);
- execcmd[2] = cmd;
-
- /* get the selection that the command will operate on */
- if (op && op != '<' && op != '!' && op != '&' && !view_selsize(win_view(EDIT)))
- {
- view_selectall(win_view(EDIT));
- }
- char* input = view_getstr(win_view(EDIT));
- size_t len = (input ? strlen(input) : 0);
- View *tags = win_view(TAGS), *edit = win_view(EDIT), *curr = win_view(FOCUSED);
+ char* input = view_getstr(win_view(EDIT));
+ size_t len = (input ? strlen(input) : 0);
+ View *tags = win_view(TAGS), *edit = win_view(EDIT), *curr = win_view(FOCUSED);
- /* execute the job */
- if (op == '!' || op == '&')
- {
- free(input);
- if (op == '&')
- {
- xpty_run(win_view(EDIT), execcmd);
- }
- else
- {
- job_start(execcmd, NULL, 0, NULL);
- }
- }
- else if (op == '>')
- {
- job_start(execcmd, input, len, tags);
- }
- else if (op == '|' || op == ':')
+ /* execute the job */
+ if (op == '!' || op == '&')
+ {
+ free(input);
+ if (op == '&')
{
- job_start(execcmd, input, len, edit);
+ xpty_run(win_view(EDIT), execcmd);
}
else
{
- job_start(execcmd, input, len, (op != '<' ? curr : edit));
+ job_start(execcmd, NULL, 0, NULL);
}
}
+ else if (op == '>')
+ {
+ job_start(execcmd, input, len, tags);
+ }
+ else if (op == '|' || op == ':')
+ {
+ job_start(execcmd, input, len, edit);
+ }
+ else
+ {
+ job_start(execcmd, input, len, (op != '<' ? curr : edit));
+ }
}
static void exec(char* cmd, char* arg)
{
(void)arg;
char* str = view_getcmd(win_view(FOCUSED));
- if (str) exec(str, NULL);
+ if (str)
+ {
+ if (xpty_active())
+ {
+ xpty_send(str);
+ }
+ else
+ {
+ exec(str, NULL);
+ }
+ }
free(str);
}