X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=96111a0e600176c5a37f8f047588bd4f5f654de8;hb=ebbac77d7416d365a2a33f159780ef0f06cc3351;hp=9a7891ed4b4799d22eef45f3a3c33e9f955c6607;hpb=7530694987596642b0b83db1c4a61f2794c20397;p=st.git diff --git a/st.c b/st.c index 9a7891e..96111a0 100644 --- a/st.c +++ b/st.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -887,11 +888,7 @@ bpress(XEvent *e) { gettimeofday(&now, NULL); /* Clear previous selection, logically and visually. */ - if(sel.ob.x != -1) { - sel.ob.x = -1; - tsetdirt(sel.nb.y, sel.ne.y); - draw(); - } + selclear(NULL); sel.mode = 1; sel.type = SEL_REGULAR; sel.oe.x = sel.ob.x = x2col(e->xbutton.x); @@ -1107,7 +1104,7 @@ brelease(XEvent *e) { selpaste(NULL); } else if(e->xbutton.button == Button1) { if(sel.mode < 2) { - sel.ob.x = -1; + selclear(NULL); } else { getbuttoninfo(e); selcopy(); @@ -1440,7 +1437,7 @@ selscroll(int orig, int n) { if(BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) { if((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) { - sel.ob.x = -1; + selclear(NULL); return; } if(sel.type == SEL_RECTANGULAR) { @@ -1950,7 +1947,7 @@ csihandle(void) { tputtab(1); break; case 'J': /* ED -- Clear screen */ - sel.ob.x = -1; + selclear(NULL); switch(csiescseq.arg[0]) { case 0: /* below */ tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); @@ -2447,7 +2444,7 @@ tputc(char *c, int len) { if(control && !(term.c.attr.mode & ATTR_GFX)) return; if(sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y)) - sel.ob.x = -1; + selclear(NULL); if(IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) { term.line[term.c.y][term.c.x].mode |= ATTR_WRAP; tnewline(1); @@ -3622,6 +3619,7 @@ int main(int argc, char *argv[]) { int bitm, xr, yr; uint wr, hr; + char *titles; xw.fw = xw.fh = xw.fx = xw.fy = 0; xw.isfixed = False; @@ -3635,8 +3633,13 @@ main(int argc, char *argv[]) { break; case 'e': /* eat all remaining arguments */ - if(argc > 1) + if(argc > 1) { opt_cmd = &argv[1]; + if(argv[1] != NULL && opt_title == NULL) { + titles = strdup(argv[1]); + opt_title = basename(titles); + } + } goto run; case 'f': opt_font = EARGF(usage());