www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - curses/ncurses liberary in D

reply pascal111 <judas.the.messiah.111 gmail.com> writes:
https://forum.dlang.org/post/bjldcmojboremdroknud forum.dlang.org

On Wednesday, 3 November 2021 at 05:43:05 UTC, harakim wrote:
 On Wednesday, 3 November 2021 at 01:39:02 UTC, H. S. Teoh wrote:
 On Wed, Nov 03, 2021 at 01:33:28AM +0000, dangbinghoo via 
 Digitalmars-d-learn wrote:
 On Wednesday, 3 November 2021 at 00:50:31 UTC, pascal111 
 wrote:
 How can I include "ncurses" liberary in D? I'm using Ubuntu 
 and GDC!
Search ncurses in Dub registray shows that there's 3 ncurses D bingdings. https://code.dlang.org/search?q=ncurses
In addition to that, I highly recommend Adam's arsd.terminal as an ncurses replacement. It's not API equivalent, but is much more idiomatic D than any ncurses binding would be. T
https://github.com/adamdruppe/arsd/blob/master/terminal.d
How can I use this terminal module? Is there a document for it?
Aug 04 2022
next sibling parent reply Adam D Ruppe <destructionator gmail.com> writes:
On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote:
 https://github.com/adamdruppe/arsd/blob/master/terminal.d
How can I use this terminal module? Is there a document for it?
http://arsd-official.dpldocs.info/arsd.terminal.html
Aug 04 2022
parent reply pascal111 <judas.the.messiah.111 gmail.com> writes:
On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote:
 On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote:
 https://github.com/adamdruppe/arsd/blob/master/terminal.d
How can I use this terminal module? Is there a document for it?
http://arsd-official.dpldocs.info/arsd.terminal.html
They didn't mention how can I determine the cursor position like C functions "wherex, wherey, gotoxy".
Aug 04 2022
parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
On Thu, Aug 04, 2022 at 11:52:48PM +0000, pascal111 via Digitalmars-d-learn
wrote:
 On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote:
 On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote:
 https://github.com/adamdruppe/arsd/blob/master/terminal.d
How can I use this terminal module? Is there a document for it?
http://arsd-official.dpldocs.info/arsd.terminal.html
They didn't mention how can I determine the cursor position like C functions "wherex, wherey, gotoxy".
Did you read the docs at all? Look at the code examples where it creates a Terminal struct. Now go to the docs and click on "Terminal" under the section "Structs", and you get to this page: http://arsd-official.dpldocs.info/arsd.terminal.Terminal.html The first code block on this page contains a full list of all the functions Terminal supports, including cursorX, cursorY, and moveTo, which are what you are looking for. (Granted, though, the main page could be expanded to include examples of how to use these functions.. take that up with Adam. :-P) T -- WINDOWS = Will Install Needless Data On Whole System -- CompuMan
Aug 04 2022
next sibling parent reply Adam D Ruppe <destructionator gmail.com> writes:
On Friday, 5 August 2022 at 04:14:22 UTC, H. S. Teoh wrote:
 including cursorX, cursorY
Worth noting these are not initialized in linear mode, only in fullscreen/cellular. I might change that soon, it is on my todo list.
 (Granted, though, the main page could be expanded to include 
 examples of how to use these functions.. take that up with 
 Adam. :-P)
Email me a patch.
Aug 05 2022
parent pascal111 <judas.the.messiah.111 gmail.com> writes:
On Friday, 5 August 2022 at 12:02:27 UTC, Adam D Ruppe wrote:
 On Friday, 5 August 2022 at 04:14:22 UTC, H. S. Teoh wrote:
 including cursorX, cursorY
Worth noting these are not initialized in linear mode, only in fullscreen/cellular. I might change that soon, it is on my todo list.
 (Granted, though, the main page could be expanded to include 
 examples of how to use these functions.. take that up with 
 Adam. :-P)
Email me a patch.
If you allow, I uploaded a copy of "terminal.d" to my account in github. The guests will think I'm professional and that I programmed all of that code of "terminal.d", I'm kidding, I know it's your effort, but I liked to make it available to others when they see I use it in my programs. https://github.com/pascal111-fra/D
Aug 05 2022
prev sibling parent reply pascal111 <judas.the.messiah.111 gmail.com> writes:
On Friday, 5 August 2022 at 04:14:22 UTC, H. S. Teoh wrote:
 On Thu, Aug 04, 2022 at 11:52:48PM +0000, pascal111 via 
 Digitalmars-d-learn wrote:
 On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote:
 On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote:
 https://github.com/adamdruppe/arsd/blob/master/terminal.d
How can I use this terminal module? Is there a document for it?
http://arsd-official.dpldocs.info/arsd.terminal.html
They didn't mention how can I determine the cursor position like C functions "wherex, wherey, gotoxy".
Did you read the docs at all? Look at the code examples where it creates a Terminal struct. Now go to the docs and click on "Terminal" under the section "Structs", and you get to this page: http://arsd-official.dpldocs.info/arsd.terminal.Terminal.html The first code block on this page contains a full list of all the functions Terminal supports, including cursorX, cursorY, and moveTo, which are what you are looking for. (Granted, though, the main page could be expanded to include examples of how to use these functions.. take that up with Adam. :-P) T
It works: '''D module temp; import std.stdio; import std.string; import std.conv; import dcollect; import std.math; import std.algorithm; import std.array; import std.functional; import arsd.terminal; int main(string[] args) { auto terminal = Terminal(ConsoleOutputType.linear); int x=30, y=3, c=1; for(auto i=1; i<=10; i++){ terminal.moveTo(x,y); terminal.writeln(strstring(c,"*")); x-=2; y++; c+=4;} return 0; } ''' But I'll need help to understand some functions like how we can use "readf" equivalent, I don't see it.
Aug 05 2022
parent Adam D Ruppe <destructionator gmail.com> writes:
On Friday, 5 August 2022 at 18:20:36 UTC, pascal111 wrote:
 But I'll need help to understand some functions like how we can 
 use "readf" equivalent, I don't see it.
http://arsd-official.dpldocs.info/arsd.terminal.html#get-line get a line then strip it and convert to whatever numbers you want etc
Aug 05 2022
prev sibling parent Paul Backus <snarwin gmail.com> writes:
On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote:
 On Wednesday, 3 November 2021 at 05:43:05 UTC, harakim wrote:
 https://github.com/adamdruppe/arsd/blob/master/terminal.d
How can I use this terminal module? Is there a document for it?
It is part of the arsd-official package, available on code.dlang.org: https://code.dlang.org/packages/arsd-official The documentation for the terminal module is here: http://arsd-official.dpldocs.info/arsd.terminal.html
Aug 04 2022