I agree with the need for something like this... I got this macro from somewhere and while it's basic, it at least lets me view the todos for a document...
Making it dockable would be a major improvement...
/**
* TODO List, by Stephen Waits <steve@waits.net>, July 28, 2001
*
* INSTALLATION
* 1. load this module in SlickEdit (Macro | Load Module)
* 2. bind a key to the command "todoList" (Tools | Configuration | Key Bindings)
*
* USAGE
* 1. start using the syntax of "TODO: check this return code" within your code comments
* 2. run the command (or hit your bound key) to pop-up a list of all TODO:'s in your file
*
*/
#include "slick.sh"
/**
* the main form. Consists basically of a modal dialog box with a single listbox
* which is created and populated in _command todoList().
*/
_form ToDoForm {
p_backcolor=0x80000005
p_border_style=BDS_DIALOG_BOX
p_caption='TODO List'
p_clip_controls=FALSE
p_forecolor=0x80000008
p_height=5565
p_tool_window=FALSE
p_width=6990
p_x=8685
p_y=5895
p_eventtab=ToDoForm
_list_box ListBoxResults {
p_auto_size=TRUE
p_backcolor=0x80000005
p_border_style=BDS_FIXED_SINGLE
p_font_bold=FALSE
p_font_italic=FALSE
p_font_name='MS Sans Serif'
p_font_size=8
p_font_underline=FALSE
p_forecolor=0x80000008
p_height=5520
p_multi_select=MS_NONE
p_scroll_bars=SB_VERTICAL
p_tab_index=1
p_tab_stop=TRUE
p_width=6997
p_x=0
p_y=0
p_eventtab2=_ul2_listbox
}
}
defeventtab ToDoForm
/**
* called when user tries to normally close the dialog. exists here so that we may
* return a -1 so the calling code doesn't try to move to line 0.
*/
void ToDoForm.on_close()
{
_delete_window(-1);
}
/**
* when a user presses enter on one of the highlighted items in the dialog box
* we figure out which item they highlighted, determine the line number, and
* return the result to the caller so that it may move the buffer appropriately.
*/
void ListBoxResults.'ENTER'()
{
// figure out what line user clicked on, and return it
p_parent._delete_window( GetLineFromListBox(ListBoxResults) );
}
/**
* same as the "ENTER" method, but for a double-click.
*/
void ListBoxResults.lbutton_double_click()
{
// figure out what line user clicked on, and return it
p_parent._delete_window( GetLineFromListBox(ListBoxResults) );
}
/**
* determine which line of the listbox is highlighted, and exctract the line number
* of the TODO: item.
*
* @return the source code line number of whichever TODO: item is currently selected in
* the listbox
*/
int GetLineFromListBox(lbid)
{
// extract the line number out of the current listbox item
parse lbid._lbget_text() with linestr description;
if ( isinteger(linestr) )
return(int)linestr;
else
return -1;
}
/**
* searches for all "TODO:"'s inside comments in the current buffer, creates
* the ToDoForm, populates that form's listbox with source code line numbers and
* the "descriptions" of each TODO:, launches the ToDoForm, and looks at the result
* to determine if the user wants us to move the buffer to a new line.
*
* @return
*/
_command todoList()
{
// find our form handles
formindex = find_index("ToDoForm", oi2type(OI_FORM)); /* TODO: error check */
// create our form
formid = _load_template(formindex, _mdi, "H"); // TODO: error check
listboxid = formid.p_child;
// setup listbox
listboxid._col_width(0, 1000);
listboxid._col_width(1);
listboxid._lbclear();
// save our original buffer position - we don't want to change it unless we have to
save_pos(p);
// start at beginning of buffer, find all "TODO:" occurrences and populate listbox
p_RLine = 0;
int rc = search("TODO:", ">NI@CC");
while ( rc == 0 )
{
// get the current line from the buffer
get_line(codeline);
// cursor should be sitting right after the "TODO:", so get column number
// (and compensate for tab characters, etc.
begcol = _text_colc(p_col,"P");
// now strip everything up to our column, this is our description
desc = strip( substr(codeline, begcol), "B");
// finally add this to the listbox
listboxid._lbadd_item(p_RLine "\t" desc);
// and continue searching!
rc = repeat_search();
}
// this makes it so that buffer looks the same when the dialog is up
restore_pos(p);
// show the user who's boss
message("TODO List, by Stephen Waits <steve@waits.net>");
// display the form
formid.p_visible = 1;
int line = (int)_modal_wait(formid);
// and handle the results, move to another buffer line if necessary
if ( line >= 0 )
{
// move the buffer
p_RLine = line;
// and do the selection
get_line(linestr);
_deselect();
_end_line();
_select_char();
p_col = 0;
p_col = _text_colc(pos("TODO:", linestr, 1, "I"), "I");
_select_char();
}
}