Need tips for a command line gui
I'm doing a project for college. It's not too complicated but it involves a lot of data access on a linked list. Does anyone have any tips for designing an intuitive command line gui? I'm doing things like:
while (current !=NULL)
for (i=1;i<10;i++)
printf("%d *Name: %s\n",i,current->data.name);
current=current->Next;
switch (get_char())
case '1' : *Access item one*
case '2' : *Access item two*
case '3' : *Access item three*
...
case '0' :
break; //displays more items
It's a bit more complicated but you get the idea. I've seen command line tools with checkmarks and such and I think they'd be very useful but unfortunately I can't find info on those anywhere.
Crushyerbones
Junior Poster in Training
53 posts since Mar 2008
Reputation Points: 10
Solved Threads: 1
I would suggest you make everything else work before getting over elaborate on the user interface.
Look at what you're required to do for the assignment and make sure you do that much first. If you've got time left at the end, then you can have fun making it look better.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
In this case, all I'm missing is a basic sorting mechanism AND the user interface :) They also happen to be very closely linked together.
Crushyerbones
Junior Poster in Training
53 posts since Mar 2008
Reputation Points: 10
Solved Threads: 1
The UI approach you posted seems fine.
A simple printf of options and reading the input for the response.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Display and UI are linked. Sorting (an underlying algorithm) is not.
The best CUIs provide maximum data display and minimum query display.
For example, your program may run something like this (bold represents user input):
% <strong>a.out</strong>
Crush Yer Bones's College Project
Mr. Teacher
Algorithms, Spring 2008
Enter 'help' for help.
> <strong>help</strong>
add Add a record to the database
delete Remove a record from the database
help Enter 'help help' for how to use the help
list List all records by title/sort criterion
open Open a database file
quit Quit
save Save changes to the database
search Search for a specific record
sort Change the criterion used to sort and list the records
view View an individual record
> <strong>help help</strong>
Enter 'help' followed by the command for which you want
more specific information. For example:
help view
displays how to use the 'view' command.
> <strong>help view</strong>
View an individual record. Use it by entering
view [OPTIONS]
where the OPTIONS are one or more of the following:
INDEX The integer index of the record to view
NAME The name of the record to view
...
If you fail to specify any required options you will be prompted
to enter them.
> <strong>view</strong>
Enter the record index (ENTER if unknown)> <strong>0</strong>
Valid record numbers are 1 to 7.
Enter the record index (ENTER if unknown)>
> <strong>list</strong>
1. Annette Johansen 5. Peter Moon
2. Billy Tsu 6. Roark Murphey
3. Miriam Leigh 7. Seanaed Murphey
4. Nuala El-Sayed
>
Etc.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
The main purpose of this project is to print a list of items based on their distance to the user's position. To make it easier to locate a particular item I was hoping for easy ways to add/remove displayed parameters (like display name and distance/names only and sort by name/display name and email adress and sort by email).
I have no idea on how to do that except by using a massive amount of conditionals.
Crushyerbones
Junior Poster in Training
53 posts since Mar 2008
Reputation Points: 10
Solved Threads: 1
> (like display name and distance/names only and sort by name/display name and email adress and sort by email).
Sounds like a spreadsheet to me.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953