www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - DlangUI 0.9.0: Console backend added

reply Vadim Lopatin <coolreader.org gmail.com> writes:
Hello!

Now it's possible to build DlangUI apps to run in console (Linux, 
Windows).
When DlangUI is built with version=USE_CONSOLE (dub 
subconfiguration "console" for dlangui library) - it works in 
terminal.

Such feature may be useful, e.g. to run apps on headless devices, 
or via SSH.

For simple apps, it's enough just to specify dlangui 
configuration console. No additional changes required.

If custom themes are used, additional theme files prefixed with 
"console_" are to be created.
If custom embedded resources are used, create additional resource 
list file, with "console_" prefix.

Margins, padding, size values if specified in pixels are to be 
changed.
Hint: use points or EMs for such values to get them working 
universally on both console and GUI.

If images/icons are used, and still needed in console mode, you 
may need to create ASCII art like text image files (.tim 
extension).

Some screenshots (from dlangui example1 app):

   http://i63.tinypic.com/2wn1bg9.png
   http://i66.tinypic.com/142yctx.png
   http://i64.tinypic.com/snlc08.png
   http://i64.tinypic.com/2n16vcw.png

Part of key modifiers do not work in linux console.
Mouse events working ok.

Theme for console is to be improved a bit.

Now I'm trying to get DlangIDE working in console.


Best regards,
      Vadim
Sep 09 2016
next sibling parent mogu <mogucpp 163.com> writes:
On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin wrote:
 Hello!

 Now it's possible to build DlangUI apps to run in console 
 (Linux, Windows).
 When DlangUI is built with version=USE_CONSOLE (dub 
 subconfiguration "console" for dlangui library) - it works in 
 terminal.

 Such feature may be useful, e.g. to run apps on headless 
 devices, or via SSH.

 For simple apps, it's enough just to specify dlangui 
 configuration console. No additional changes required.

 If custom themes are used, additional theme files prefixed with 
 "console_" are to be created.
 If custom embedded resources are used, create additional 
 resource list file, with "console_" prefix.

 Margins, padding, size values if specified in pixels are to be 
 changed.
 Hint: use points or EMs for such values to get them working 
 universally on both console and GUI.

 If images/icons are used, and still needed in console mode, you 
 may need to create ASCII art like text image files (.tim 
 extension).

 Some screenshots (from dlangui example1 app):

   http://i63.tinypic.com/2wn1bg9.png
   http://i66.tinypic.com/142yctx.png
   http://i64.tinypic.com/snlc08.png
   http://i64.tinypic.com/2n16vcw.png

 Part of key modifiers do not work in linux console.
 Mouse events working ok.

 Theme for console is to be improved a bit.

 Now I'm trying to get DlangIDE working in console.


 Best regards,
      Vadim
Amazing!!!!! You must be genius.
Sep 09 2016
prev sibling next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin wrote:
 Now it's possible to build DlangUI apps to run in console 
 (Linux, Windows).
Very nice.
 Part of key modifiers do not work in linux console.
 Mouse events working ok.
Which parts are you having trouble with? I have implemented a lot of this for my terminal.d and might be able to help.
Sep 09 2016
parent reply Vadim Lopatin <coolreader.org gmail.com> writes:
On Friday, 9 September 2016 at 11:56:11 UTC, Adam D. Ruppe wrote:
 On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin 
 wrote:
 Now it's possible to build DlangUI apps to run in console 
 (Linux, Windows).
Very nice.
 Part of key modifiers do not work in linux console.
 Mouse events working ok.
Which parts are you having trouble with? I have implemented a lot of this for my terminal.d and might be able to help.
Keyboard support on Linux terminals seems most difficult. Some shortcuts are being processed by terminal app. Some ctrl-combinations are causing signals. I have an idea to catch some of Ctrl+key signals, and simulate keypress. E.g. I cannot get working text selection moving by Ctrl+Shift+Arrows. UI layout code required surprisingly a few changes. Most of console related fixes were made by providing separate theme file. Only hardcoded margins/padding/size limits were needed to fix.
Sep 09 2016
next sibling parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Friday, 9 September 2016 at 12:20:08 UTC, Vadim Lopatin wrote:
 Keyboard support on Linux terminals seems most difficult.
 Some shortcuts are being processed by terminal app.
here programmer has no options.
 Some ctrl-combinations are causing signals.
switch tty to raw mode, and there will be no signals. see my iv.rawtty2, for example.
 E.g. I cannot get working text selection moving by 
 Ctrl+Shift+Arrows.
this is hightly dependent of the actual terminal emulator. in real world, it is enough to support xterm mappings, rxvt mappings and "Linux" (this is "real" console) mappings. xterm and rxvt mappings aren't really conflicting (much). again, the messy iv.rawtty2.ttyReadKey may give some clues. of course, "best practice" is to use termcap/terminfo, but this is even bigger mess! ;-)
Sep 09 2016
parent reply Vadim Lopatin <coolreader.org gmail.com> writes:
On Friday, 9 September 2016 at 12:33:56 UTC, ketmar wrote:
 On Friday, 9 September 2016 at 12:20:08 UTC, Vadim Lopatin 
 wrote:
 Keyboard support on Linux terminals seems most difficult.
 Some shortcuts are being processed by terminal app.
here programmer has no options.
 Some ctrl-combinations are causing signals.
switch tty to raw mode, and there will be no signals. see my iv.rawtty2, for example.
 E.g. I cannot get working text selection moving by 
 Ctrl+Shift+Arrows.
this is hightly dependent of the actual terminal emulator. in real world, it is enough to support xterm mappings, rxvt mappings and "Linux" (this is "real" console) mappings. xterm and rxvt mappings aren't really conflicting (much). again, the messy iv.rawtty2.ttyReadKey may give some clues. of course, "best practice" is to use termcap/terminfo, but this is even bigger mess! ;-)
Thank you! I'll look at it.
Sep 09 2016
parent ketmar <ketmar ketmar.no-ip.org> writes:
On Friday, 9 September 2016 at 12:52:35 UTC, Vadim Lopatin wrote:
 Thank you!
 I'll look at it.
feel free to ping me on IRC if you'll have any questions.
Sep 09 2016
prev sibling parent Rory McGuire via Digitalmars-d-announce writes:
On Fri, Sep 9, 2016 at 2:20 PM, Vadim Lopatin via Digitalmars-d-announce <
digitalmars-d-announce puremagic.com> wrote:

 On Friday, 9 September 2016 at 11:56:11 UTC, Adam D. Ruppe wrote:

 On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin wrote:

 Now it's possible to build DlangUI apps to run in console (Linux,
 Windows).
Very nice. Part of key modifiers do not work in linux console.
 Mouse events working ok.
Which parts are you having trouble with? I have implemented a lot of this for my terminal.d and might be able to help.
Keyboard support on Linux terminals seems most difficult.
Hi Vadim, [0] is a short raw keyboard example, uses Jason's io, libasync and termios: https://gist.github.com/rjmcguire/58f3fd3d5f0934dc351cd143c1b0c880 It has quite a lot of comments, it is an experiment for keyboard io, so I guess it might fit into dlangui nicely. R
Sep 12 2016
prev sibling next sibling parent reply =?UTF-8?Q?Martin_Dra=c5=a1ar?= via Digitalmars-d-announce writes:
Dne 9.9.2016 v 13:21 Vadim Lopatin via Digitalmars-d-announce napsal(a):
 Hello!
 
 Now it's possible to build DlangUI apps to run in console (Linux, Windows).
 When DlangUI is built with version=USE_CONSOLE (dub subconfiguration
 "console" for dlangui library) - it works in terminal.
This is indeed really cool. How gracefully does it handle when the console is of limited size? Let's say 80x25. Does it allow e.g. virtual screen of bigger size and then moving around in console? Martin
Sep 09 2016
parent Vadim Lopatin <coolreader.org gmail.com> writes:
On Friday, 9 September 2016 at 12:04:14 UTC, Martin DraĊĦar wrote:
 Dne 9.9.2016 v 13:21 Vadim Lopatin via Digitalmars-d-announce 
 napsal(a):
 Hello!
 
 Now it's possible to build DlangUI apps to run in console 
 (Linux, Windows).
 When DlangUI is built with version=USE_CONSOLE (dub 
 subconfiguration
 "console" for dlangui library) - it works in terminal.
This is indeed really cool. How gracefully does it handle when the console is of limited size? Let's say 80x25. Does it allow e.g. virtual screen of bigger size and then moving around in console? Martin
DlangUI provides "layouts" similar to Android ones, which should reflow and resize widgets for different screen sizes. As well, app may load layouts from DML markup file - different for different screen size (as it's done in Android). To simulate bigger screen, it's possible just to place controls inside ScrollWidget - and you would be able to move it with scrollbars.
Sep 09 2016
prev sibling next sibling parent Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
On 09/09/2016 07:21 AM, Vadim Lopatin wrote:
 Hello!

 Now it's possible to build DlangUI apps to run in console (Linux, Windows).

 Some screenshots (from dlangui example1 app):

    http://i63.tinypic.com/2wn1bg9.png
    http://i66.tinypic.com/142yctx.png
    http://i64.tinypic.com/snlc08.png
    http://i64.tinypic.com/2n16vcw.png
Very cool!
Sep 09 2016
prev sibling next sibling parent reply Steve Biedermann <steve.biedermann.privat gmail.com> writes:
On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin wrote:
 Now it's possible to build DlangUI apps to run in console 
 (Linux, Windows).
 When DlangUI is built with version=USE_CONSOLE (dub 
 subconfiguration "console" for dlangui library) - it works in 
 terminal.
I just tried to compiel with subconfiguration "console" but I'm getting compile errors: dub build --force Performing "debug" build using dmd for x86. dlangui 0.9.1: building configuration "console"... %APPDATA%\dub\packages\dlangui-0.9.1\dlangui\3rd party\fontconfig\package.d(7,12): Error: module loader is in file 'derelict\util\loader.d' which cannot be read import path[0] = %APPDATA%\dub\packages\dlangui-0.9.1\dlangui\3rdparty import path[1] = %APPDATA%\dub\packages\dlangui-0.9.1\dlangui\src import path[2] = C:\D\dmd2\windows\bin\..\..\src\phobos import path[3] = C:\D\dmd2\windows\bin\..\..\src\druntime\import dmd failed with exit code 1.
Sep 12 2016
parent Vadim Lopatin <coolreader.org gmail.com> writes:
On Monday, 12 September 2016 at 08:15:57 UTC, Steve Biedermann 
wrote:
 On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin 
 wrote:
 Now it's possible to build DlangUI apps to run in console 
 (Linux, Windows).
 When DlangUI is built with version=USE_CONSOLE (dub 
 subconfiguration "console" for dlangui library) - it works in 
 terminal.
I just tried to compiel with subconfiguration "console" but I'm getting compile errors: dub build --force Performing "debug" build using dmd for x86. dlangui 0.9.1: building configuration "console"... %APPDATA%\dub\packages\dlangui-0.9.1\dlangui\3rd party\fontconfig\package.d(7,12): Error: module loader is in file 'derelict\util\loader.d' which cannot be read import path[0] = %APPDATA%\dub\packages\dlangui-0.9.1\dlangui\3rdparty import path[1] = %APPDATA%\dub\packages\dlangui-0.9.1\dlangui\src import path[2] = C:\D\dmd2\windows\bin\..\..\src\phobos import path[3] = C:\D\dmd2\windows\bin\..\..\src\druntime\import dmd failed with exit code 1.
Must be fixed in v0.9.2 (once dub registry updated version)
Sep 12 2016
prev sibling next sibling parent reply Vadim Lopatin <coolreader.org gmail.com> writes:
On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin wrote:
 Hello!

 Now it's possible to build DlangUI apps to run in console 
 (Linux, Windows).
 When DlangUI is built with version=USE_CONSOLE (dub 
 subconfiguration "console" for dlangui library) - it works in 
 terminal.

 Such feature may be useful, e.g. to run apps on headless 
 devices, or via SSH.

 For simple apps, it's enough just to specify dlangui 
 configuration console. No additional changes required.

 If custom themes are used, additional theme files prefixed with 
 "console_" are to be created.
 If custom embedded resources are used, create additional 
 resource list file, with "console_" prefix.

 Margins, padding, size values if specified in pixels are to be 
 changed.
 Hint: use points or EMs for such values to get them working 
 universally on both console and GUI.

 If images/icons are used, and still needed in console mode, you 
 may need to create ASCII art like text image files (.tim 
 extension).
Screenshot of DlangIDE working in console: http://i68.tinypic.com/2hrmkup.png
Sep 13 2016
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Tuesday, 13 September 2016 at 07:51:06 UTC, Vadim Lopatin 
wrote:
 On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin 
 wrote:
 [...]
Screenshot of DlangIDE working in console: http://i68.tinypic.com/2hrmkup.png
Looks great! can you fix dlang-ui to build on XP ?
Sep 13 2016
parent Vadim Lopatin <coolreader.org gmail.com> writes:
On Tuesday, 13 September 2016 at 11:27:19 UTC, Stefan Koch wrote:
 On Tuesday, 13 September 2016 at 07:51:06 UTC, Vadim Lopatin 
 wrote:
 On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin 
 wrote:
 [...]
Screenshot of DlangIDE working in console: http://i68.tinypic.com/2hrmkup.png
Looks great! can you fix dlang-ui to build on XP ?
I don't have XP to check. What is wrong? Could you submit issue on github? https://github.com/buggins/dlangui/issues
Sep 13 2016
prev sibling parent reply Bauss <jj_1337 live.dk> writes:
On Friday, 9 September 2016 at 11:21:07 UTC, Vadim Lopatin wrote:
 Some screenshots (from dlangui example1 app):

   http://i63.tinypic.com/2wn1bg9.png
   http://i66.tinypic.com/142yctx.png
   http://i64.tinypic.com/snlc08.png
   http://i64.tinypic.com/2n16vcw.png
Good job, but why do people still use tinypic in 2016, when things like imgur exist that are a 1000 times faster to use, no dirty ads and images won't magically be taken down someday.
Sep 13 2016
next sibling parent Vadim Lopatin <coolreader.org gmail.com> writes:
On Tuesday, 13 September 2016 at 12:18:19 UTC, Bauss wrote:
 Good job, but why do people still use tinypic in 2016, when 
 things like imgur exist that are a 1000 times faster to use, no 
 dirty ads and images won't magically be taken down someday.
Thanks. I just googled tinypic with "free image hosting". Next time will upload on imgur.
Sep 13 2016
prev sibling parent reply Vadim Lopatin <coolreader.org gmail.com> writes:
On Tuesday, 13 September 2016 at 12:18:19 UTC, Bauss wrote:
 Good job, but why do people still use tinypic in 2016, when 
 things like imgur exist that are a 1000 times faster to use, no 
 dirty ads and images won't magically be taken down someday.
Screenshots on imgur: http://imgur.com/a/eaRiT
Sep 13 2016
next sibling parent reply Rory McGuire via Digitalmars-d-announce writes:
On Tue, Sep 13, 2016 at 2:29 PM, Vadim Lopatin via Digitalmars-d-announce <
digitalmars-d-announce puremagic.com> wrote:

 On Tuesday, 13 September 2016 at 12:18:19 UTC, Bauss wrote:

 Good job, but why do people still use tinypic in 2016, when things like
 imgur exist that are a 1000 times faster to use, no dirty ads and images
 won't magically be taken down someday.
Screenshots on imgur: http://imgur.com/a/eaRiT
nice, much better image site.. Did you get my post about the keyboard thing? You can test it by running dub --single filename.d output looks like: kp: [27, 91, 49, 59, 50, 68] kp: [27, 91, 49, 59, 53, 68] kp: [27, 91, 49, 59, 51, 68] kp: [27, 91, 68] if I press: shift+Left ctrl+Left alt+left left BTW: love what you are doing with dlangui. Are you a one person team?
Sep 13 2016
parent Vadim Lopatin <coolreader.org gmail.com> writes:
On Tuesday, 13 September 2016 at 12:50:02 UTC, Rory McGuire wrote:
 Did you get my post about the keyboard thing?
 You can test it by running dub --single filename.d

 output looks like:
 kp: [27, 91, 49, 59, 50, 68]
 kp: [27, 91, 49, 59, 53, 68]
 kp: [27, 91, 49, 59, 51, 68]
 kp: [27, 91, 68]

 if I press:
 shift+Left
 ctrl+Left
 alt+left
 left
Single modifiers are working ok for me. But some combinations - do not. E.g. Ctrl+Shift+Left/Up/Down - at least in Gnome terminal.
 BTW: love what you are doing with dlangui. Are you a one person 
 team?
In general, yes. But there were 24 contributors who sent pull requests. Some of them contributed a lot of PRs - e.g. g4z3r(54 commits), MyLittleRobo(20 commits). It would be great if more developers joined dlangui. But it should become more usable and popular, to attract more people. One of stopper here is probably poor documentation.
Sep 13 2016
prev sibling parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Tuesday, 13 September 2016 at 12:29:47 UTC, Vadim Lopatin 
wrote:
 Screenshots on imgur: http://imgur.com/a/eaRiT
btw. please note that on most GNU/Linux terminals you can use simple RGB colors (with each component in [0..5] range). IRL if $TERM != "Linux", it is safe to assume that terminal supports 256 colors (with rare exclustions like "screen" -- those can be safely ignored, screen is fubared anyway ;-).
Sep 13 2016
parent reply Vadim Lopatin <coolreader.org gmail.com> writes:
On Tuesday, 13 September 2016 at 13:40:32 UTC, ketmar wrote:
 On Tuesday, 13 September 2016 at 12:29:47 UTC, Vadim Lopatin 
 wrote:
 Screenshots on imgur: http://imgur.com/a/eaRiT
btw. please note that on most GNU/Linux terminals you can use simple RGB colors (with each component in [0..5] range). IRL if $TERM != "Linux", it is safe to assume that terminal supports 256 colors (with rare exclustions like "screen" -- those can be safely ignored, screen is fubared anyway ;-).
Thank you! Now dlangui terminal mode supports only 16 colors. Some refactoring is required to support RGB colors.
Sep 13 2016
parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Wednesday, 14 September 2016 at 05:58:51 UTC, Vadim Lopatin 
wrote:
 Thank you!
 Now dlangui terminal mode supports only 16 colors.
 Some refactoring is required to support RGB colors.
in my editor i'm simply using rgb in [0..255] range, and mapping that to what terminal has. yet it is probably not the best way to make something nice looking when only 16 colors are available. heh, i should try and see how it will look like! ;-) On Wednesday, 14 September 2016 at 06:06:51 UTC, Vadim Lopatin wrote:
 at least in Gnome terminal.
maybe gnome terminal took those keys for it's own needs -- like tab switching or something. in xterm, those are usual CSI-with-modifier codes: \e[1;<mod><char>, where <mod> is 6 for ctrl+shift, and <char> is A/B/C/D for Up/Down/Right/Left respectively. it is better to check everything in xterm -- this is still the most used terminal emulator out there. just switch it to send <esc> for alt-key instead of setting high bit. ;-)
Sep 14 2016
next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
On Wednesday, 14 September 2016 at 13:04:40 UTC, ketmar wrote:
 On Wednesday, 14 September 2016 at 05:58:51 UTC, Vadim Lopatin 
 CSI-with-modifier codes: \e[1;<mod><char>
this is common format for keys with modifiers, actually. let me quote my rawtty2: bool xtermMods (uint mci) nogc { switch (mci) { case 2: key.shift = true; return true; case 3: key.alt = true; return true; case 4: key.alt = true; key.shift = true; return true; case 5: key.ctrl = true; return true; case 6: key.ctrl = true; key.shift = true; return true; case 7: key.alt = true; key.ctrl = true; return true; case 8: key.alt = true; key.ctrl = true; key.shift = true; return true; default: } return false; } void xtermSpecial (char ch) nogc { switch (ch) { case 'A': key.key = TtyKey.Key.Up; break; case 'B': key.key = TtyKey.Key.Down; break; case 'C': key.key = TtyKey.Key.Right; break; case 'D': key.key = TtyKey.Key.Left; break; case 'E': key.key = TtyKey.Key.Pad5; break; case 'H': key.key = TtyKey.Key.Home; break; case 'F': key.key = TtyKey.Key.End; break; case 'P': key.key = TtyKey.Key.F1; break; case 'Q': key.key = TtyKey.Key.F2; break; case 'R': key.key = TtyKey.Key.F3; break; case 'S': key.key = TtyKey.Key.F4; break; case 'Z': key.key = TtyKey.Key.Tab; key.ch = 9; if (!key.shift && !key.alt && !key.ctrl) key.shift = true; break; default: badCSI(); break; } }
Sep 14 2016
prev sibling next sibling parent reply Rory McGuire via Digitalmars-d-announce writes:
On Wed, Sep 14, 2016 at 3:04 PM, ketmar via Digitalmars-d-announce <
digitalmars-d-announce puremagic.com> wrote:

 On Wednesday, 14 September 2016 at 05:58:51 UTC, Vadim Lopatin wrote:

 Thank you!
 Now dlangui terminal mode supports only 16 colors.
 Some refactoring is required to support RGB colors.
in my editor i'm simply using rgb in [0..255] range, and mapping that to what terminal has. yet it is probably not the best way to make something nice looking when only 16 colors are available. heh, i should try and see how it will look like! ;-)
Screenshots here are what can be done with terminal/ascii: http://caca.zoy.org/wiki/libcaca
Sep 14 2016
parent reply ketmar <ketmar ketmar.no-ip.org> writes:
On Wednesday, 14 September 2016 at 13:08:18 UTC, Rory McGuire 
wrote:
 Screenshots here are what can be done with terminal/ascii: 
 http://caca.zoy.org/wiki/libcaca
still, you can't use shading charaters to color text, so 16 colors for text output won't look that impressive. ;-)
Sep 14 2016
parent Rory McGuire via Digitalmars-d-announce writes:
On Wed, Sep 14, 2016 at 3:11 PM, ketmar via Digitalmars-d-announce <
digitalmars-d-announce puremagic.com> wrote:

 On Wednesday, 14 September 2016 at 13:08:18 UTC, Rory McGuire wrote:

 Screenshots here are what can be done with terminal/ascii:
 http://caca.zoy.org/wiki/libcaca
still, you can't use shading charaters to color text, so 16 colors for text output won't look that impressive. ;-)
:) true
Sep 14 2016
prev sibling next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
p.p.s. yep, VT-100 had only 4 functional keys, so we still 
enjoying having 'em encoded separately from the others.
Sep 14 2016
prev sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
On Wednesday, 14 September 2016 at 13:04:40 UTC, ketmar wrote:
 in my editor i'm simply using rgb in [0..255] range, and 
 mapping that to what terminal has. yet it is probably not the 
 best way to make something nice looking when only 16 colors are 
 available. heh, i should try and see how it will look like! ;-)
actually, it's not that bad, i expected much worser results. original 256 color mode: http://ketmar.no-ip.org/img/tui/tui_c256.png and this is restricted to basic 16 colors: http://ketmar.no-ip.org/img/tui/tui_c16a.png still readable. my terminal has somewhat non-standard first 16 colors (some colors are brighter than default xterm, some are not), that's probably why background becomes so bright. but it is still readable. and this is 16 colors with "weighted translation" (0.30*r+0.59*g+0.11*b). looks surprisingly clean: http://ketmar.no-ip.org/img/tui/tui_c16b.png
Sep 14 2016