Grim - Development Plan (first draft)


PHENOTYPE - (what the user sees) (don't understand any of this? did you want to go home?)
The Grim Message Keeper will load up (optionally) on startup, assuming you are in init 3 (X does not automatically load up) and print messages (or just number of new messages, etc. depending on configuration)... and act a reminder system. To go further, it requires accessing the command line arguments - listed below.

Command Line Arguments
grim -c
::: Display the number of messages only. (e.g. 6 messages. 3 unread.)

grim -v [all (default); read; unread]
::: View message titles only. Options self-explanitory.

grim -r [all (default); number of message(s); unread; read]
::: Lists the message titles and bodies. With number of message (or messages.. e.g grim -r 1 3). Can use with range options e.g. grim -r 1-3 6 8-10 (reads 1,2,3,6,8,9,10). Can't use numbers with unread - will list all unread.

grim -w
::: Write new message.

grim -e [number of message]
::: Edit message. e.g grim -e 2 (edit message 2)

grim -d [all; number of message(s); read; unread]
::: Delete message. With 'all', delete all messages; '[un]read', delete all [un]read messages; number, that message or range of messages (much like grim -r)

grim --help
::: Display help.

grim --version
::: Display version number.

grim --about
::: Display about message.

grim --suggestions?
::: Anything I should add? (not a real option!!)

User Config
- what to display on startup (just message titles/just number of messages/just unread messages/just unread messages titles/all full messages/custom)
- colors of message titles/message titles?
- order by date - asc or desc
- can config by editing .bashrc - grim [argument] [options]

GENOTYPE - (what we see!)
The program will be broken down into classes. An ordinary text file (probably a .grim_msgs) will be used to store messages.

The classes/variables/functions

class Messages
{
	public:
	void count_message();
	void add_message();
	void edit_message();
	void del_message();
	void view_message();
	void read_message();
} msg;


/* to access, use msg.add_message(); (etc) */

The database
All the messages are to be stored in a text file (.grim_msgs)..


---%---%---
^ This is the title
// date (this one just made up)
// users don't need to edit this
// if they do edit, perhaps have "last edited" and created?
$ 04959939333

% Message goes here, where each line in the message is prefixed by a
"%"
% or any suitable prefix. The advantage of this is that the delimiter,
% ie, "---%<--->%---" (or anything else) cannot appear in the middle of
% the text to confuse the program. That is, even if the user types the
% delimiter on a seperate line, it'll be prefixed with the prefix (%),
% like so:
% ---%<--->%---
% So no worries about it.

---%---%---
.. etc


The actual body of the message is the part prefixed by "% ".

Yes, I know, it (---%<...) is exactly like Wyatt's end tag, but, it's a
delimiter.

There are many advantages of such a format. One of them is detailed in
the body of the first message (ie, delimiter in text). The next
advantage is that your "count" function becomes as simple as going
through the file, matching lines with "---%---%---", and counting the
number of such lines. (In fact, it's easier. Think about it.)

When printing out the message, you can read it one line at a time and
stop reading when you reach a line with no % prefix, or an empty line,
whichever you prefer. See, no message length needed!

-Arvind

My notes: start reading at the first % under the ---%---%--- delimiter, 
end at the last one, for the message body. Get line starting with ^ for 
message title, : for date.

For reading message 'x', go to the x occurance of ---%---%--- and do as above

Editing will be done with their favourite editor (VIM,Emacs,etc)

Arvind's suggestions... 

The accepted way is to put it in a file and call 
the
user's $EDITOR editor on that file. Let them edit it. As soon as 
they're
done (editor exits), read in the input from the file.

Print the contents of the other messages (upto the message which is to
be edited). Then, print out the edited file (instead of the old
message). Print the rest of the file. I don't think I made myself very
clear. Tell me if that's the case, I'll explain it better this time.

Let me try:
x's represent the messages above the one to be edited.
y's represent the message to be edited.
z's represent the messages below the one to be edited.

x
x
y
z
z

Now, put the "y" in a new file. After editing that file, let the
changed contents be represented by "a". So, print the file upto y, 
which
are the "x"s.

x
x

Then, print the edited file (which is an "a").

a

Then, print the other messages.

z
z

The whole file is now:

x
x
a
z
z

The message is effectively edited! Yeah, yeah, I know it's not a very
good explaination, but, I tried!

My comment:
p.s. Printing without % - just have it remove the first 2 characters from the line.. 

Development dicussion/submitted code/ideas
New! Arvind comments on body1.txt (see index page). here.
New! Kamran - Solution to the Problem of Ranges - here.

Arvind sent in his suggestions - refers to others' comments below. Here!

Wyatt has been a great help.. helping me learn C++, his idea about using classes.. main thing now is the text database stuff.. some of his suggestions on that (quite long and extensive.. useful!!): clicky!

Matt: Line counter - prints how many messages - assumes message stored on one line.. shows how to use command line arguments... over here.
"My idea is to have just one program called "grim", instead of another program just to count the messages. We could just have a command line option that say "grim -c" or "grim --count" that would count the Messages. You could then just put in your .bash_profile "grim -c" instead of running the other program.. "

LavaDevil (written in C): expansion of first test here.

My stuff: struct - add 2 messages - then pick which one to print - stored in structured array (no text file). here!

Please send comments/suggestions!!

Hosted by www.Geocities.ws

1