Re: Prevent console line advancing on user input

2023-04-06 Thread anonymouse via Digitalmars-d-learn
On Thursday, 6 April 2023 at 14:51:43 UTC, Steven Schveighoffer wrote: On 4/6/23 4:01 AM, anonymouse wrote: Wondering if this is possible? [snip] You need to use a terminal-control library, such as `arsd.terminal` https://github.com/adamdruppe/arsd/blob/master/terminal.d -Steve That works

Re: Prevent console line advancing on user input

2023-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/6/23 4:01 AM, anonymouse wrote: Wondering if this is possible? Ask a user at input and wait for response: write("Is the sky blue? "); readf!" %s\n"(response); If the user's response is correct, I'd like to change the color of provided response to indicate it was correct then advance to th

Prevent console line advancing on user input

2023-04-06 Thread anonymouse via Digitalmars-d-learn
Wondering if this is possible? Ask a user at input and wait for response: write("Is the sky blue? "); readf!" %s\n"(response); If the user's response is correct, I'd like to change the color of provided response to indicate it was correct then advance to the next line and ask a different ques

Re: User input

2017-11-08 Thread Ali Çehreli via Digitalmars-d-learn
On 11/08/2017 09:19 AM, Namal wrote: Is there any other way to do a simple user input into integer variables without using std.conv? import std.stdio; void main() { int i; readf(" %s", &i);// You can use %d as well // You can wrap readf in a function templ

User input

2017-11-08 Thread Namal via Digitalmars-d-learn
Is there any other way to do a simple user input into integer variables without using std.conv?

Re: Convert user input string to Regex

2017-09-16 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:23:14 UTC, Adam D. Ruppe wrote: On Saturday, 16 September 2017 at 03:18:31 UTC, Ky-Anh Huynh wrote: Is there a way to transform user input string to a regular expression? For example, I want to write a `grep`-like program import std.regex; auto re = regex

Re: Convert user input string to Regex

2017-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:18:31 UTC, Ky-Anh Huynh wrote: Is there a way to transform user input string to a regular expression? For example, I want to write a `grep`-like program import std.regex; auto re = regex(user_pattern, user_flags); You'll probably want to split it o

Convert user input string to Regex

2017-09-15 Thread Ky-Anh Huynh via Digitalmars-d-learn
Hi, Is there a way to transform user input string to a regular expression? For example, I want to write a `grep`-like program ``` mygrep -E '/pattern/i' file.txt ``` and here the user's parameter `/pattern/i` would be converted to a Regex object. Fyi, in Ruby, `to_regexp`

Re: User input; quick question.

2017-04-29 Thread fred via Digitalmars-d-learn
On Saturday, 29 April 2017 at 21:18:27 UTC, cym13 wrote: On Saturday, 29 April 2017 at 21:09:13 UTC, fred wrote: import std.stdio; I am somewhat new to D, and I am trying to receive user input, like this, with a prompt: string str; writeln("Enter a string: "); str = readln; w

Re: User input; quick question.

2017-04-29 Thread cym13 via Digitalmars-d-learn
On Saturday, 29 April 2017 at 21:09:13 UTC, fred wrote: import std.stdio; I am somewhat new to D, and I am trying to receive user input, like this, with a prompt: string str; writeln("Enter a string: "); str = readln; writeln(str); However, the prompt appears after I enter the

User input; quick question.

2017-04-29 Thread fred via Digitalmars-d-learn
import std.stdio; I am somewhat new to D, and I am trying to receive user input, like this, with a prompt: string str; writeln("Enter a string: "); str = readln; writeln(str); However, the prompt appears after I enter the input; any reason why? I've trawled the internet

Re: Gtkd how to filter TreeView according to user input

2017-01-17 Thread Erdem via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 19:07:21 UTC, Ali Çehreli wrote: On 01/17/2017 01:25 AM, Erdem wrote: > void main(string[] args) > { > Main.init(args); > new MyWindow(); > Main.run(); > } I have no experience with Gtkd but the code inside main looks fundamentally wrong. One would ex

Re: Gtkd how to filter TreeView according to user input

2017-01-17 Thread Ali Çehreli via Digitalmars-d-learn
On 01/17/2017 01:25 AM, Erdem wrote: > void main(string[] args) > { > Main.init(args); > new MyWindow(); > Main.run(); > } I have no experience with Gtkd but the code inside main looks fundamentally wrong. One would expect you to do something with the MyWindow object: auto w

Gtkd how to filter TreeView according to user input

2017-01-17 Thread Erdem via Digitalmars-d-learn
I'd like to filter Treeview data according to user input. How should I do that? When I run this program it gives segmentation fault error. import gtk.Main; import gtk.MainWindow; import gtk.Box; import gtk.Entry; import gtk.EditableIF; import gtk.TreeModelFilter; import gtk.TreeView; i

Re: User input parsing

2015-10-14 Thread Joel via Digitalmars-d-learn
Thanks guys. I did think of regex, but I don't know how to learn it.

Re: User input parsing

2015-10-14 Thread Ali Çehreli via Digitalmars-d-learn
On 10/14/2015 12:14 AM, Joel wrote: Is there a fast way to get a number out of a text input? Like getting '1.5' out of 'sdaz1.5;['. Here's what I have at the moment: string processValue(string s) { string ns; foreach(c; s) { if

Re: User input parsing

2015-10-14 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 07:14:45 UTC, Joel wrote: Is there a fast way to get a number out of a text input? Like getting '1.5' out of 'sdaz1.5;['. Here's what I have at the moment: string processValue(string s) { string ns;

User input parsing

2015-10-14 Thread Joel via Digitalmars-d-learn
Is there a fast way to get a number out of a text input? Like getting '1.5' out of 'sdaz1.5;['. Here's what I have at the moment: string processValue(string s) { string ns; foreach(c; s) {

Re: User input readline || readf

2015-04-23 Thread Dennis Ritchie via Digitalmars-d-learn
It also works: - import std.conv; import std.stdio; import std.string; struct Human { string name; ushort age; } void print_human_list(Human[] human_list) { foreach(human; human_list) { writeln(human.name); writeln(human.age);

Re: User input readline || readf

2015-04-23 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 23 April 2015 at 17:18:01 UTC, kerze wrote: Hy, i'm new @ D and i come from python. Sorry for my engish, i understand good, but i write like a cow spanish. I make a little programm to add human's name and age and a function to write out alls humans in the list. Here is the sour

Re: User input readline || readf

2015-04-23 Thread kerze via Digitalmars-d-learn
Willkommen in der D Community. ;) So many Thanks @Steven and Jacques, answer's more than a only; "do this" ;)

Re: User input readline || readf

2015-04-23 Thread via Digitalmars-d-learn
The paste is still there. readf leaves the \n from pressing enter in stdin, which gets read by the next function that's accessing it. I answered a similiar question in another thread: http://forum.dlang.org/post/jwxfaztgsyzwqpzaj...@forum.dlang.org I see two other mistakes in your code as well:

Re: User input readline || readf

2015-04-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/23/15 1:17 PM, kerze wrote: The problem is, it writes instant "Name: Age:" at the standart output. readf reads the element from the stream, and NOTHING MORE, it leaves the newline on the stream. So the next readf then reads the newline as a string. You can fix this by using readf(" %s"

Re: User input readline || readf

2015-04-23 Thread kerze via Digitalmars-d-learn
hmm the paste is away ?!? here i post my source one more time. [code] import std.stdio; import std.string; struct Human { string name; ushort age; }; void print_human_list(Human[] human_list){ foreach(human; human_list){ writeln(human.name); writeln(human.age);

User input readline || readf

2015-04-23 Thread kerze via Digitalmars-d-learn
Hy, i'm new @ D and i come from python. Sorry for my engish, i understand good, but i write like a cow spanish. I make a little programm to add human's name and age and a function to write out alls humans in the list. Here is the source: http://dpaste.dzfl.pl/0a0da462225d The problem is, i