LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Position cursor in std i/o window

You know the little blinking cursor in the standard i/o window that NI opens the first time I do a printf() in my main program? I want to change it's position when the user hits the left arrow, for example (I use GetKey() to retrieve the key). I tried SetCursorPos() but this moves the mouse. I tried SetStdioWindowPosition () but, that (predictably) moves the whole window. So how do I move the little blinking cursor inside of the window??!!!
Thanks in advance
jcl
0 Kudos
Message 1 of 14
(4,362 Views)
Hello MrPonny,

The Stdio window isn't like any other text entry/word processor window where the mouse will jump to the location that is pressed.
In order to simulate this, you can add extra spaces or newline characters when the user clicks on the stdio window to position the cursor to the desired location. You might also want to use the GetCursorPos() function to calculate how many spaces and new line character you need to print out to the window in order to position the cursor where the user clicked.

Hope that helps.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 14
(4,341 Views)
What I want to do is use the foward & back arrows to traverse a displayed string. So I would like to put the little blinking cursor under a letter as the user presses these arrow keys.
Thanks
0 Kudos
Message 3 of 14
(4,332 Views)
What would the user be able to do, other than move a cursor?
Knowing nothing about your application, I'd suggest you drop the Standard I/O window and use a textbox on a panel. You can then give the user access to any of the standard Windows editing cut and paste, etc., operations.
I would use the Standard I/O window only for the most rudimentary applications.
0 Kudos
Message 4 of 14
(4,329 Views)
I have to agree with Al, the standard i/o window is pretty useless for most things. About the only thing I ever use it for is displaying debug messages while developing some tricky code.

A text box is probably a much better way to go.
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 5 of 14
(4,312 Views)
I'm wanting to provide a command line interface. The thing is, this app will probably be ported to embedded linux so I want to avoid as much windows dependency as possible...
jcl
0 Kudos
Message 6 of 14
(4,302 Views)
COmmand line interfaces (under any operating system) generally don't let you just position the cursor anywhere you want on the screen.
Using the ANSI C scanf function, the user can use the cursor keys (left/right arrows, backspace, delete) to edit their own entry. Is that enough? Any other functions that allow full screen editing or positioning the cursor anywhere on the screen will not be portable to C compilers across operating systems.
Have you looked at using Java?
0 Kudos
Message 7 of 14
(4,289 Views)
Here is some code that may clarify where I'm having my problem:

while(1)
{
printf("\nPrompt>");
while ((Key = GetKey()) != ENTER_KEY)
{
if (isalnum((char)Key) || (Key == ' ') || (ispunct ((char)Key)))
putchar(Key);
else if ((Key ==LEFT_ARROW_KEY) || (Key ==LEFT_ARROW_KEY))
---> Move cursor to new position in command line;
}
executeCmd();
}

so say the user enters "ACmdHere", the screen will show:
Prompt>ACmdHere_ where the underscore is the blinking cursor

Now say the user realizes he really wanted to type "ACmdOverHere". So he wants to back arrow and add the "Over" in between "Cmd" and "Here". Of course he can backpace to "Cmd" and then type in "OverHere" but when the commands are long this is not really the option he will want. As he back arrows I would like to display the cursor in the position where editing will take place. Any ideas?
jcl
0 Kudos
Message 8 of 14
(4,283 Views)
scanf() and gets(), both ANSI C functions which will be portable to any platform, handle the cursor keys and allow editing until you press Enter.
If you know the command format, you can use scanf() to read the line and parse individual parameters.
If the command format varies based on the command, you can use gets() to read the entire line, then parse the command. gets() is probably your best choice.

char cmdLine[256];

while(1)
{
printf("\nPrompt>");
gets(cmdLine);
executeCmd(cmdLine);
}
0 Kudos
Message 9 of 14
(4,277 Views)
I'm not having a problem parsing the command string. My problem is displaying the cursor anywhere but at the end of the displayed string...
jcl
0 Kudos
Message 10 of 14
(4,274 Views)