Re: Update roll-up on my arsd libraries

2017-04-14 Thread Adam D. Ruppe via Digitalmars-d-announce

On Friday, 14 April 2017 at 19:55:54 UTC, Jerry wrote:
You have mixed spaces and tabs, not in the good way either. 
https://github.com/adamdruppe/arsd/blob/master/simpledisplay.d#L3642


Some code is copied from C headers, some come from open source 
contributors who may use different styles than I do. I accept 
these gifts in the spirit in which they are given.


If I edit that code, I might reformat it, but it isn't important 
to me.


Re: Update roll-up on my arsd libraries

2017-04-14 Thread Jerry via Digitalmars-d-announce
You have mixed spaces and tabs, not in the good way either. 
https://github.com/adamdruppe/arsd/blob/master/simpledisplay.d#L3642





Re: Update roll-up on my arsd libraries

2017-04-14 Thread Adam D. Ruppe via Digitalmars-d-announce

On Friday, 14 April 2017 at 06:23:00 UTC, Basile B. wrote:
Thanks particularly for this one, which is certainly a 
reference about how to use the nightmare-ish X11 API in D.


I actually don't think X is that bad for what it does. just 
that it is ridiculously underpowered compared to the competition.


If you want a real nightmare, take a look at terminal.d's 
innards. Eeek.


Re: Update roll-up on my arsd libraries

2017-04-14 Thread Basile B. via Digitalmars-d-announce

On Thursday, 13 April 2017 at 16:04:18 UTC, Adam D. Ruppe wrote:
I haven't posted in announce for a while, so I figured I'd give 
you guys an update on what's been happening in my libs. This 
message is a big long, so feel free to just skim to see if you 
are interested in anything.


[...]

* simpledisplay.d has gotten a LOT of work lately.


Thanks particularly for this one, which is certainly a reference 
about how to use the nightmare-ish X11 API in D.





Re: Update roll-up on my arsd libraries

2017-04-13 Thread Adam D. Ruppe via Digitalmars-d-announce

On Thursday, 13 April 2017 at 18:11:10 UTC, H. S. Teoh wrote:

Hooray!  Finally!  Maybe now I can play videos over SSH (albeit
ultra-pixelated). :-P


Hah though actually, my terminal emulator has support for 
outputting png images...


But truth is, this is one reason why I prefer things like 
`attach` or the new simpledisplay feature to VNC and the like - I 
can then combine programs from different computers on one 
desktop. So if I do need to play videos, I get them in the 
compressed format over whatever link and play them locally on the 
laptop.


I rarely run browsers remotely, even though sometimes I wish I 
could just because the local one tends to be much easier to use.



And on that note, I've been playing around with my own 
range-like abstractions over Terminal (variously called Display 
or Canvas), that lets you treat rectangular subsets of the 
Terminal as sub-terminals in their own right (as least as far 
as output is concerned).


Nice. I actually thought about doing something like that 
(basically nested ScrollbackBuffers with a nicer api) too, but 
haven't gotten around to it yet.


Now *this* really caught my eye.  I'm gonna hafta check it out 
just for this feature alone.  It has always annoyed me that 
although such a thing has always been *possible* for a 
network-oriented GUI protocol like X11, hardly any programs (if 
at all!) are written in a way that would work this way.



Indeed. So the way it works right now is there's an 
XDisconnectException that is thrown. If you want to recover, you 
must catch it OUTSIDE the event loop, then adjust the display 
string if appropriate and run 
XDisplayConnection.discardAndRecreate. If it succeeds, you can 
reenter your event loop and pick up where you left off.


Any X resources you had may need to be recreated. The library 
will automatically handle things it has inside (SimpleWindow 
right now, I'll add support to the other classes soon) but if you 
go outside it, you might have to do it yourself.


Server-side fonts, in particular, may need attention because they 
might no longer be available. But I might automate that too (keep 
a list of fallbacks inside the class).


Well, anyway, the big point is it isn't 100% automatic, you do 
need to catch the exception, possibly fix some stuff, and 
reconnect, but it is almost automatic; in simple apps, it is as 
simple as `catch(...) discardAndRecreate(); loopAgain;`


But it DOES work! :P

Awesome!!!  I always hated those bulky toolkit libraries that 
includes everything and the kitchen sink -- 90% of which you 
don't actually need in your application, which usually means 
you have a ton of dependencies that aren't actually necessary 
and library dependency hell when you ship your binaries.


Yeah, I avoid distributing most programs because I can't stand 
having 20 MB + of stuff and the poor users have to manage that 
crap. Gah.


And I avoid *compiling* most gui programs because that's a huge 
pain too. But not with minigui, you've used my libs, you know how 
it is


dmd yourapp.d minigui simpledisplay color

Boom, it works. There's a few tweaks you can do, you might want 
some of the optional add on modules (which I am keeping each one 
strictly independent - they are not allowed to import each other 
to keep that decoupled), but the basic of it is right there.


And it builds in a fraction of a second. No meta-object compiler, 
no bindings generation, no dlls. And the generated file can be as 
small as 200 KB if you strip it right, though my test programs 
tend to hover closer to 600 on Windows, ~800 on Linux. I can 
handle that a lot easier than 20,000 KB.


Adding widgets is just newing the class. The automatic layout is 
usually ok. Custom widgets? Just subclass (actually until 
yesterday, it was all done via delegates, but subclassing is 
actually a bit easier, thanks D's anonymous classes) and 
implement paint and events. Again, no multiple files to generate 
and compile.



I think we could write a killer app on top of this.  Say a 
terminal that travels with you wherever you go -- migratable 
from desktop to laptop on wifi and back, perhaps even to/from 
your


Actually, I already have that: `attach` in the terminal emulator 
repo (it is similar to GNU screen, just my style, including 
things like scrollback, window icons, mouse support, and more).


My "IDE" tends to be an attach session running everything I want 
in the terminal tabs and I grab them by name when moving around.


That's the big reason why I have spent more time on terminal.d 
than minigui.d until now: my terminal sessions follow me on the 
laptop and such, so I wrote a LOT of terminal programs. But now, 
I can do GUI too! So we'll see how it goes.


The one problem I have with a quick migration is that the gui one 
is still somewhat bandwidth inefficient. Just rolling your mouse 
over a window generates several KB of network traffic. On a real 
connection... no big deal, but sometimes I use my laptop on a 

Re: Update roll-up on my arsd libraries

2017-04-13 Thread H. S. Teoh via Digitalmars-d-announce
On Thu, Apr 13, 2017 at 04:04:18PM +, Adam D. Ruppe via 
Digitalmars-d-announce wrote:
[...]
> * terminal.d is a terminal client library, similar to ncurses. It
> allows you to move the cursor around the terminal, go to full screen
> mode, output color, input all keys and mouse events.

I've been using terminal.d for a lot of my projects.  It's a really nice
terminal library that has a much better (IMO) API than the crawling mess
that is ncurses. Thanks so much for sharing it!


> In recent months, it has gained 24-bit color output support (with
> automatic approximation to lower color fallback), though I generally
> suggest you keep to 8 color output for best results in terminal
> programs.

Hooray!  Finally!  Maybe now I can play videos over SSH (albeit
ultra-pixelated). :-P


> It also got a `getline` function with user editing and autocompletion
> available, unified some of the key input events, and a
> ScrollbackBuffer which is clunky to use, but allows you to have
> individual scroll buffers scattered around the screen.

Very nice. So far I've been rolling my own for user input, but it's nice
to have built-in support.

And on that note, I've been playing around with my own range-like
abstractions over Terminal (variously called Display or Canvas), that
lets you treat rectangular subsets of the Terminal as sub-terminals in
their own right (as least as far as output is concerned).  Basically,
there's an isCanvas template that acknowledges anything that has moveTo
and writef as a canvas-like type (and obviously designed so that
Terminal automatically qualifies), along with a series of introspection
templates to identify if a canvas has a clear method, a flush method,
etc.. On top of this there's a subcanvas UFCS function that lets you
create arbitrary rectangular views over any canvas (with automatic
moveTo coordinate translations, etc.).  So I can write code that will
work either directly with a Terminal, or any other Terminal-like
backends as well as arbitrary rectangular subregions.


[...]
> * simpledisplay.d has gotten a LOT of work lately.

I've been eyeing SDL (via Derelict) recently... but maybe if
simpledisplay.d does what I need, I might just use it instead.  Leaner
and meaner is always better, I think!


[...]
>   - simpledisplay.d can now survive an X server disconnect, and can
>   even migrate windows from one X server to another! Think GNU Screen
>   for GUI apps.

Now *this* really caught my eye.  I'm gonna hafta check it out just for
this feature alone.  It has always annoyed me that although such a thing
has always been *possible* for a network-oriented GUI protocol like X11,
hardly any programs (if at all!) are written in a way that would work
this way.  This is a really awesome feature and now I'm *really* tempted
to try it out!


[...]
> I haven't used SDL or anything similar for years thanks to
> simpledisplay.d.  Its only dependency is color.d, leading to simple
> builds.

Now I'm very tempted to look into simpledisplay.d instead of SDL.


> * And the huge one in the last month, minigui.d is a small GUI widget
> library that aims to use native widgets on Windows and a small set of
> custom ones on Linux (in the future, it might also support GTK
> widgets, though I don't plan to write that myself, there is just
> another user who said he might). It has no dependencies except for
> simpledisplay.d and color.d and the operating system - no complicated
> library build process, no huge dlls to distribute with your program.

Awesome!!!  I always hated those bulky toolkit libraries that includes
everything and the kitchen sink -- 90% of which you don't actually need
in your application, which usually means you have a ton of dependencies
that aren't actually necessary and library dependency hell when you ship
your binaries.


[...]
> It automatically sizes and lays out your widgets and has an event
> system similar to Javascript. With add on modules like minigui_xml,
> you can create windows from XML definitions, and it is script.d
> compatible. When I'm ready, I'll post that too, and hopefully you can
> take basic web knowledge over to desktop land... without just
> embedding browsers and calling them desktop apps. My largest program
> is about 800 KB, and that's all it needs.

That's cool, man.  Now I gotta check this out too! :-P


> Since it is built on simpledisplay, it also gets X connection
> disconnect survival or migration!

This is a killer feature, IMO.


[...]
> I'll write more about minigui.d and do a separate announcement for it
> when it reaches version 1.0, which will probably be in about another
> month.

Awesome!


[...]
> Look forward to more on this, it is close to being ready for general
> use, and then we'll have another chapter in the D gui ecosystem.
> dlangui , I hope you like some
> friendly competition :)

This looks like a potential awesome trend, especially that bit about X
server disconnection survival / migration.  I