Hi Guys,

The ToDo List script is a nice idea but is broken in version 4.5.4(2356). I have
mended it, improved the menu appearance and added an About box so that those who
aren't familiar know how to use it and filtering to prevent it from reporting on
SVN directories. You can remove this or change it to handle other version
control systems, or anything else, if you wish. Just replace the existing code,
accessed via Scripts/Todo list/View Script and replace the existing code with
the following code, then select Scripts/Recompile scripts.

=================

/**
 *  PSPad Todo script
 *  (c) by Carney
 *
 */

var module_name = "TodoListJS";
var module_ver = "0.10";

function openScript() {
  var obj1 = newEditor();
  obj1.openFile(moduleFileName("TodoListJS"));
}


var fs = new ActiveXObject("Scripting.FileSystemObject")

function findTodos(filename) {
  var txt = "";
  var r, re, line;
  var i = 0;
  var fr;

  re = new RegExp("TODO:");
  fr = fs.GetFile(filename).OpenAsTextStream(1, 0);

  while (!fr.AtEndOfStream) {
    line = fr.ReadLine();
    i++;
    r = line.search(re);
    if (r != -1) {
      txt = txt.concat(filename + ": "+ i +": " + line.substr(r) + "\n");
    }
  }
  fr.Close( );

  return txt;
}

function todoList() {
  var data = "";
  var fr;
  var obj1 = NewEditor(); //New editor object
  var i = 0;
  var todos = "";
  var r, re;
  
  re = new RegExp(".svn");
  for (i = 0; i < (projectFilesCount()-1); i++) {
    fr = projectFiles(i);
    
     // Skip SVN directories.
     r = fr.search(re);
     if(r != -1){
       continue;
     }
    
    if (fs.FileExists(fr)) {
    todos = findTodos(fr);
    if(todos != ""){
      data = data.concat(todos);
    }
//       echo(data);
    }
//    echo(ddd);
  }

  logClear();         // clearing log window
  var lines = new Array();
  lines = data.split('\n');
  for(var x in lines)
  {
    logAddLine(lines[x]);   // printing the result to the log
  }
}

function about() 
{
        /*      Extension description, how to use, license, 
                open source project web address, and developer 
                credits.        
        */

        echo(
                "\n" + module_name + " " + module_ver + "\n\n" +
                "PSPad Todo script\n\n" +
                "by Carney\n\n" +
                "This script looks for TODO statements in the\n" +
    "current project and displays them in the log.\n\n" +
    "Your statements should start with\n\n" +
    "\"TODO:\"\n\n" +
    "in order to be found."
        );
        return;
}


function Init(){
  addMenuItem("View ToDos", "ToDo list", "todoList");
  addMenuItem("View Script", "ToDo list", "openScript");
        addMenuItem("-","ToDo list","","");                                     
                                                                        // Menu 
divider
  addMenuItem("About", "ToDo list", "about");
}

=================

The forum has killed the indentation but you can use PSPad to fix that. :-)

Cheers.

-- 
<http://forum.pspad.com/read.php?2,50573,50573>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem