/* txtGTD - text-based 'Getting Things Done' system Copyright (C) 2009 Marcin 'BishKopt' Woroch http://smietnik.xon.pl/txtgtd/ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see Contact me by e-mail: BishKopt aatt gmail ddoott com */ ; OPTIONS ;#g:: ;uncomment this line and the line below to start only with (not automatically): WIN+G ;hotkey := 1 naprefix := " ! " ;next action prefix naincprefix := " - " ;how should all next action look like in context lists escapetag := " " ;escape (e.g. non-next action not to be interpreted as a next action nor project); you can also escape e.g. project descriptions cindicator := " //" ;context section indicator cprefix := " @" ;context prefix noncontext := "! These are the next actions without context (assign context to them) !" ;name of non-context-next-actions-list filename projects := "projects.txt" ;path to your projects list (remember of windows slashes! "\") fpath := "TODO" ;path to the folder where the context files will be put to; also a global context list filename global := 2 ;1: make only folder with separate context files; 2: make folder with separate context files AND 'global' contexts file (with all contexts); 3: make only 'global' file with all contexts pincontext := 2 ;do you want the projects names to be added inbracets next to the action in context files? no = 0, yes = 1, shortened version = 2 pincoffset := 11 ;how many characters should shortened version of project name contain? beep := 1 ;shall I beep evertytime i refresh the lists? ; END OF OPTIONS IfNotExist, %projects% { MsgBox, 0,, The file %projects% does not exist! Exiting. Exit } ;;;autoloop;;; lastmod := 0 Loop { FileGetTime, mod, %projects% EnvSub, lastmod, mod, seconds if (lastmod < 0) { ;;;autoloop;;; FileRemoveDir, %fpath%, 1 FileCreateDir, %fpath% currentproject := "" Loop, Read, %projects% { If (InStr(A_LoopReadLine, "\S") != 0 AND InStr(A_LoopReadLine, escapetag) != 1 AND InStr(A_LoopReadLine, naprefix) != 1) ;line is not empty AND line does not begin with escapetag NOR naprefix { currentproject := A_LoopReadLine } else if (InStr(A_LoopReadLine, naprefix) = 1) ;is it next action? { ciposition := InStr(A_LoopReadLine, cindicator cprefix) if (ciposition != 0) ;does it contain context information? { contexts := SubStr(A_LoopReadLine, ciposition + StrLen(cindicator)+StrLen(cprefix)) ;extract the contexts (i also cut off the first cprefix) StringTrimRight, action, A_LoopReadLine, StrLen(contexts)+StrLen(cindicator)+StrLen(cprefix) ;cuts context off from the action and saves in 'action' StringReplace, contexts, contexts, %cprefix%, ``, all ;replace each cprefix with an accent StringSplit, contexts, contexts, `` ;convert contexts into an array by accents } else ;next action without context { contexts0 := 1 contexts1 := noncontext action := A_LoopReadLine } Loop, %contexts0% { filename := contexts%A_index% IfNotExist, %fpath%/%filename%.txt { StringUpper, uppercontext, filename FileAppend, %uppercontext%, %fpath%/%filename%.txt } } StringReplace, action, action, %naprefix%, %naincprefix% ;changes the next action prefix look in context lists if (currentproject != "") ;if (the action is assigned to any project (nonproject actions (single actions) are on top of the projects file) { if (pincontext = 1) action := action " (" currentproject ")" else if (pincontext = 2) { if (StrLen(currentproject) > pincoffset) action := action " (" SubStr(currentproject, 1, pincoffset)"...)" else action := action " (" currentproject ")" } } Loop, %contexts0% { filename := contexts%A_index% FileAppend, `n%action%, %fpath%/%filename%.txt } } } if (global = 1 OR global = 3) { IfExist, %fpath%.txt { FileDelete, %fpath%.txt } FileList = Loop, %fpath%/*.txt FileList = %FileList%%A_LoopFileName%`n Sort, FileList Loop, parse, FileList, `n { if A_LoopField = ; Ignore the blank item at the end of the list. continue FileRead, text, %fpath%/%A_LoopField% if (A_Index != 1) FileAppend, `n`n, %fpath%.txt FileAppend, %text%, %fpath%.txt } if (global = 3) { FileRemoveDir, %fpath%, 1 } } ;;;autoloop;;; if (beep = 1) { SoundBeep } } lastmod := mod if (hotkey = 1) { break } } sleep, 1000 ;;;autoloop;;;