[dev] [st] selection bugfix

2013-05-26 Thread p37sitdu
The fix is for st HEAD.

First of all, how to reproduce:
1. Run "man man" or just "less" with some scrollable file.
2. Select some part of text by pressing LMB somewhere and moving cursor
up.
3. Scroll with "j" and "k".

The result is: http://postimg.org/image/ec04tz7u5/

The problem is that if you select this way, sel.e.y is less than
sel.b.x.  selected() function expects sel.b.y and sel.e.y to be the
"sorted" version of sel.bx, ..., sel.ey variables.

To fix this problem, I moved the code that sorts these variables to
separate function "selsort" and replaced code that just copied sel.bx,
.., sel.ey to sel.b.x, ..., sel.e.y with the call to selsort.

This also fixes another problem with rectangular selection.  If you
select backwards with alt pressed and then scroll, rectangular selection
just disappears.

Patch is attached.
diff --git a/st.c b/st.c
index 8475878..99c3468 100644
--- a/st.c
+++ b/st.c
@@ -249,11 +249,10 @@ typedef struct {
int mode;
int type;
int snap;
-   int bx, by;
-   int ex, ey;
+   int bx, by, ex, ey;
struct {
int x, y;
-   } b, e;
+   } b, e; /* same as bx, ..., ey, but swapped if by > ey */
char *clip;
Atom xtarget;
bool alt;
@@ -390,6 +389,7 @@ static void selclear(XEvent *);
 static void selrequest(XEvent *);
 
 static void selinit(void);
+static void selsort(void);
 static inline bool selected(int, int);
 static void selcopy(void);
 static void selscroll(int, int);
@@ -658,21 +658,23 @@ y2row(int y) {
return LIMIT(y, 0, term.row-1);
 }
 
+static void
+selsort(void) {
+   sel.b.x = sel.by < sel.ey ? sel.bx : sel.ex;
+   sel.b.y = MIN(sel.by, sel.ey);
+   sel.e.x = sel.by < sel.ey ? sel.ex : sel.bx;
+   sel.e.y = MAX(sel.by, sel.ey);
+}
+
 static inline bool
 selected(int x, int y) {
-   int bx, ex;
-
-   if(sel.ey == y && sel.by == y) {
-   bx = MIN(sel.bx, sel.ex);
-   ex = MAX(sel.bx, sel.ex);
-
-   return BETWEEN(x, bx, ex);
-   }
+   if(sel.e.y == y && sel.b.y == y)
+   return BETWEEN(x, sel.b.x, sel.e.x);
 
-   if(sel.type == SEL_RECTANGULAR) {
+   if(sel.type == SEL_RECTANGULAR)
return ((sel.b.y <= y && y <= sel.e.y)
&& (sel.b.x <= x && x <= sel.e.x));
-   }
+
return ((sel.b.y < y && y < sel.e.y)
|| (y == sel.e.y && x <= sel.e.x))
|| (y == sel.b.y && x >= sel.b.x
@@ -774,11 +776,7 @@ getbuttoninfo(XEvent *e) {
selsnap(sel.snap, &sel.bx, &sel.by, +1);
}
 
-   sel.b.x = sel.by < sel.ey ? sel.bx : sel.ex;
-   sel.b.y = MIN(sel.by, sel.ey);
-   sel.e.x = sel.by < sel.ey ? sel.ex : sel.bx;
-   sel.e.y = MAX(sel.by, sel.ey);
-
+   selsort();
sel.type = SEL_REGULAR;
for(type = 1; type < LEN(selmasks); ++type) {
if(match(selmasks[type], state)) {
@@ -882,10 +880,8 @@ bpress(XEvent *e) {
}
selsnap(sel.snap, &sel.bx, &sel.by, -1);
selsnap(sel.snap, &sel.ex, &sel.ey, +1);
-   sel.b.x = sel.bx;
-   sel.b.y = sel.by;
-   sel.e.x = sel.ex;
-   sel.e.y = sel.ey;
+
+   selsort();
 
/*
 * Draw selection, unless it's regular and we don't want to
@@ -,9 +1107,8 @@ bmotion(XEvent *e) {
oldsey = sel.e.y;
getbuttoninfo(e);
 
-   if(oldey != sel.ey || oldex != sel.ex) {
+   if(oldey != sel.ey || oldex != sel.ex)
tsetdirt(MIN(sel.b.y, oldsby), MAX(sel.e.y, oldsey));
-   }
 }
 
 void
@@ -1434,8 +1429,7 @@ selscroll(int orig, int n) {
sel.ex = term.col;
}
}
-   sel.b.y = sel.by, sel.b.x = sel.bx;
-   sel.e.y = sel.ey, sel.e.x = sel.ex;
+   selsort();
}
 }
 


Re: [dev] [st] selection bugfix

2013-05-26 Thread Christoph Lohmann
Greetings.

On Sun, 26 May 2013 13:08:09 +0200 p37si...@lavabit.com wrote:
> The fix is for st HEAD.

Thanks,  I’ve  applied it and renamed the variables in for the selection
too, which saves some lines in st.

Please  check  out  HEAD of st and see if this works for you as you need
it.


Sincerely,

Christoph Lohmann




Re: [dev] Re: Why HTTP is so bad?

2013-05-26 Thread Random832

On 05/25/2013 12:55 AM, Strake wrote:
Yes. Thus I can easily swap out any component, or insert mediators 
between components. For example, I could write my own fetcher to scrub 
the HTTP headers, or block ads; and I wouldn't need plug-ins to view 
PDFs or watch movies. 
Why is the requirement that it conform to your IPC protocol* less 
onerous than requiring it to conform to a particular in-process API that 
would make it a "plug-in"?


*which has to handle navigation on both ends, A] what happens when you 
click a link in your viewer and B] what happens to your viewer when the 
user navigates away from it. Also, is the browser required to download 
the whole file before opening the viewer, or can for example a PDF 
viewer display the first page before the last page is downloaded? Also 
for large files (highly relevant to a movie viewer) with a file format 
that allows it, you could take advantage of range fetching, but in both 
of these cases the viewer has to speak HTTP and just be told a URL by 
the navigation component.




Re: [dev] upload via html?

2013-05-26 Thread Random832

On 05/25/2013 07:29 PM, Nicolas Braud-Santoni wrote:

Well, SFTP requires you to create a user account. (I'm aware that it may
not be one with which you can SSH in).
Some people might not want this.
Everything runs as a user. You could use www-data, whatever anonymous 
FTP uses, or simply "nobody". There's no fundamental reason you couldn't 
write an SFTP daemon that allows anonymous access.


However, this doesn't exist by default. Also, and this is something many 
people may not know, it's non-trivial to make an account that cannot be 
used for _port forwarding_ - simply making it impossible to log in with 
a shell [e.g. shell set to /bin/false] doesn't accomplish this.




Re: [dev] Re: Why HTTP is so bad?

2013-05-26 Thread Dmitrij Czarkoff
On May 26, 2013 3:08 PM, "Random832"  wrote:
> Why is the requirement that it conform to your IPC protocol* less onerous
than requiring it to conform to a particular in-process API that would make
it a "plug-in"?

May it owe to the fact that this particular IPC protocol is *the* protocol
used for nearly all IPC in the system?

> *which has to handle navigation on both ends, A] what happens when you
click a link in your viewer and B] what happens to your viewer when the
user navigates away from it.

Try lynx and see.

> Also, is the browser required to download the whole file before opening
the viewer, or can for example a PDF viewer display the first page before
the last page is downloaded?

How does this problem differ from downloading a file from URI in IRC chat
or from mail? Why should it be solved differently in browser then?


Dmitrij D. Czarkoff


[dev] [sbase / 9base] Still working on it?

2013-05-26 Thread Hugues

Hi
I would like to know the current state of 9base & sbase projects. Are 
you still working on it?
I'm asking because the community isn't mentioning them often, and we 
don't know the progress (even if I often check git logs)


Best Regards
--
H MoV.



Re: [dev] [sbase / 9base] Still working on it?

2013-05-26 Thread Carlos Torres
sbase and 9base are still used.  i use 9base every day :).  if you
think there is any part of p9port that should be in 9base port it.
and send a patch.  not much work goes into these since they don't
aspire to having all the gnu options... what more do you need?

--Carlos

On Sun, May 26, 2013 at 11:53 AM, Hugues  wrote:
> Hi
> I would like to know the current state of 9base & sbase projects. Are you
> still working on it?
> I'm asking because the community isn't mentioning them often, and we don't
> know the progress (even if I often check git logs)
>
> Best Regards
> --
> H MoV.
>