Author Topic: ToDo List Keyword  (Read 29488 times)

Gilmo

  • New Community Member
  • Posts: 1
  • Hero Points: 0
ToDo List Keyword
« on: May 18, 2010, 04:41:51 pm »
Hello Everybody,

Is it possible to make SlickEdit recognize ToDo keyword and generate a ToDo Report? It is almost like Javadoc style. Eclipse has support for ToDo so I was wondering if SlickEdit can support this feature.

Thanks,
Gil

vivitron

  • Senior Community Member
  • Posts: 162
  • Hero Points: 10
Re: ToDo List Keyword
« Reply #1 on: May 27, 2010, 06:17:06 pm »
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...


Code: [Select]
/**
 * 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();
}
}


chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: ToDo List Keyword
« Reply #2 on: May 27, 2010, 09:40:11 pm »
These two macros may be helpful:

CodeMarkup -- highlights a variety of formats of action comments (such as TODO: or NOTE: or BUGBUG: or etc).
FindIn -- the CodeMarkup macro can invoke this macro to find all action comments in file(s).

hp

  • Community Member
  • Posts: 31
  • Hero Points: 1
Re: ToDo List Keyword
« Reply #3 on: May 28, 2010, 08:17:47 am »
What I normally do is a file search with "//TODO" over the whole project and let the result report as a list in the search window. Works like a charm and the functionality is about the same as what you get in Eclipse. Might be a tad slow on large projects though...

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: ToDo List Keyword
« Reply #4 on: May 28, 2010, 03:11:20 pm »
It wouldn't take much to insert those items into the Message List tool window. As for why we don't offer this functionality, all I can say is that there are non-technical reasons preventing it.

Graeme

  • Senior Community Member
  • Posts: 2494
  • Hero Points: 325
Re: ToDo List Keyword
« Reply #5 on: May 29, 2010, 01:12:47 am »
A Microsoft patent perhaps?

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: ToDo List Keyword
« Reply #6 on: May 29, 2010, 02:21:02 pm »
SE can provide the method and someone can finish it, or there must be a workaround.

MartyL

  • Senior Community Member
  • Posts: 162
  • Hero Points: 27
  • Synergex
Re: ToDo List Keyword
« Reply #7 on: June 01, 2010, 06:21:39 pm »
I saw this thread when it first started and thought that this sounded like a pretty useful feature. I've been working on it off and on when time allows and now there's something to show for it. The attached file is a fully implemented SlickEdit toolbar that wraps some todo searching functionality.

All you need to do is load the source file and the toolbar will initialize itself correctly. Right-click on the toolbar for the commands (also available via command line). The general idea is that it will search all of the source files in your workspace for TODO: statements and create a handy list for you to interact with. I've added a little more in there by allowing for priority levels and naming for the TODO statements.

High priority:
Code: [Select]
// TODO! bug#12345:
// TODO !bug#12345:
// TODO!bug#12345:
// TODO!:

Important priority:
Code: [Select]
// TODO^ bug#12345:
// TODO ^bug#12345:
// TODO^bug#12345:
// TODO^:

Regular priority:
Code: [Select]
// TODO bug#12345:
// TODObug#12345:
// TODO:

The priority and title parsing may include some additional overhead (an extra regular expression). For users that are seeing sluggish performance, you can turn the extra parsing off via the "Use TDML" option on the right-click menu.

I highly recommend that you backup your SlickEdit configuration directory before loading this module. I have done fairly extensive testing, but there is no way that I can replicate everyone's configuration. Also, this has only been tested on SlickEdit 15.0.0. If you load it on other versions you do so at your own risk!

This feature has it's own thread in the user macro forum. Please get the latest version from that location:
http://community.slickedit.com/index.php?topic=6129.0
« Last Edit: June 03, 2010, 03:36:04 pm by MartyL »

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: ToDo List Keyword
« Reply #8 on: June 01, 2010, 06:56:17 pm »
 :D

WOW

what a nice surprise  8)

will test more and let you know.

regards
ehab

MartyL

  • Senior Community Member
  • Posts: 162
  • Hero Points: 27
  • Synergex
Re: ToDo List Keyword
« Reply #9 on: June 01, 2010, 06:59:31 pm »
Screen capture against SlickEdit's macro files.

Looks like the slick team could find some use for this toolbar.  ;)

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: ToDo List Keyword
« Reply #10 on: June 01, 2010, 07:05:39 pm »
quick results :

Case 1 on the SE-linux invoking generate to do list from right click menu outcomes:

Code: [Select]
Invalid argument
todo.ex 728 todo:RenderTree()   p_window_id: 377   p_object: OI_TREE_VIEW   p_name: todo_tree
todo.ex 1300 ToDo_SortByProject()   p_window_id: 377   p_object: OI_TREE_VIEW   p_name: todo_tree
todo.ex 1357 ToDo_GenerateList()   p_window_id: 377   p_object: OI_TREE_VIEW   p_name: todo_tree

Case 2 on SE-windows for VS2010 solution workspace invoking generate to do list from right click menu outcomes:

nothing.

?

MartyL

  • Senior Community Member
  • Posts: 162
  • Hero Points: 27
  • Synergex
Re: ToDo List Keyword
« Reply #11 on: June 01, 2010, 07:08:56 pm »
I'm seeing the result that you're seeing on the VS2010 solution. Looks like I need to account for another format.

Mind posting a sample linux vpj that I can have a look at?

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: ToDo List Keyword
« Reply #12 on: June 01, 2010, 07:13:59 pm »
MartyL:

attached is a plain workspace and project files made using SE 15 Linux.

hope this helps you help us : )

thanks

MartyL

  • Senior Community Member
  • Posts: 162
  • Hero Points: 27
  • Synergex
Re: ToDo List Keyword
« Reply #13 on: June 01, 2010, 07:54:06 pm »
@ehab

The file in the first post now supports Visual Studio projects (tested against VS2010). I'm attaching a file in this post that includes debug code so I can troubleshoot your linux issue. When you run the Generate it should open a vsapi window. Ctrl+C will copy the contents. Post that here when you have a chance.

Thanks!
Marty
« Last Edit: June 01, 2010, 08:48:38 pm by MartyL »

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: ToDo List Keyword
« Reply #14 on: June 01, 2010, 08:08:55 pm »
is there a manual way to show vsapi under linux ? i only get what posted before Slick-C stack window.

can this api be for windows only, i am saying this because i am using X windows sever from outside the linux machine so it can happen it does not show at all or not supported?

maybe i'll try it out on another machine.
« Last Edit: June 01, 2010, 08:17:39 pm by ehab »