Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Prompt / Console

Author
Message
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 14th Aug 2006 06:59 Edited at: 14th Aug 2006 12:55
[edit]Forgot to mention in the subject that this is for DBP[/edit]
This is a basic, general purpose prompt/console. Note that this has no specific functionality such as command parsing or anything.

Customize the console for your needs:
You can easily customize the text color and background color.
You can also edit the left/top/right/bottom edges of the window of the prompt - good if you only want it to be in a certain part of the screen.
Easily turn off input echo to hide passwords or whatever.
Easily limit the characters a user can input (such as allowing only alpha-numeric, etc).
Global variables are hidden in a type of one global variable to make it easier to add to an existing program.

Cursor movement:
You can go through previous entries using up/down keys.
As you're typing at it, you can move the cursor around on the line you are currently entering using the left/right arrow keys - handy for editing typos in the middle of the line, and editing previous entries before re-entering them.

The cursor is a blinking underscore but it is very easy to make a vertical line or whatever you want by editing the show and hide cursor functions.

Wrapping and scrolling:
When you're entering a line, if it is wider than the console window text will naturally wrap around to the next line.
When you get to the bottom of the console everything in it will automatically scroll up one line at a time as needed without affecting the rest of the screen.

Uses:
This can be the start of a command prompt simulation.
This can be used in hacking games that use a prompt.
This can be used for getting input from the user and displaying output without affecting anything else on the screen.

Anyone interested in a command prompt simulator can go here: http://thegamecreators.com/?m=codebase_view&i=be65dd609b2a1ddb2c6526c68e3e097c to find my linux command prompt simulator (submitted by my old and mostly unused handle). In fact much of the code for this prompt is from the linux command prompt simulator. The linux command prompt simulator has many standard commands, including cat, cd, clear, date, echo, id, ls, mkdir, mv, cp, rm, rmdir, sleep, su, touch, whoami and several commands accept common command-line options.



I made this for my logo parser program but I hope this helps whoever else that needs a prompt!
Wolf Dreamer
19
Years of Service
User Offline
Joined: 13th Sep 2005
Location: the land of chaotic dreams
Posted: 18th Aug 2006 02:46
This will be very useful. Thank you.

The last sane human being in a world gone mad.
If you were a cockroach, what type of cockroach would you be?
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 18th Aug 2006 21:04
Thanks.

I added the home/end keys to skip to the start and end of the line and I added the ability to set the cursor blink rate, the initial delay after you first press a key, and the repeat delay when holding down a key.
Wolf Dreamer
19
Years of Service
User Offline
Joined: 13th Sep 2005
Location: the land of chaotic dreams
Posted: 19th Aug 2006 02:01
How about selecting things with the mouse.

Checking the location of the mouse when the left button pressed, and then its current position, and where released, and highlighting that section of text between those locations. Right click makes a menu appear, copy, paste, cut, whatever.

If you were using this in an online game, and instead of sending it to part of the screen you sent it to someone else, and they had it appear in their chat box, then that might be useful.

Or click on the name of one of the people in the zone chatting, and have their profile load up, or just add them to your friends or ignore list.

I wonder if those guys that were doing that DBP open source community MMORPG have anything like that working yet.

The last sane human being in a world gone mad.
If you were a cockroach, what type of cockroach would you be?

Login to post a reply

Server time is: 2024-11-23 03:19:53
Your offset time is: 2024-11-23 03:19:53