Skip to content

Commit

Permalink
Add color for started task item
Browse files Browse the repository at this point in the history
  • Loading branch information
albuemil committed Oct 3, 2022
1 parent aa81ca5 commit db227e0
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 49 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ coverage
typings
out
.vscode-test

# Emils changes
.history/*

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Manage todo lists with ease. Powerful, easy to use and customizable. [View the d
- **Portable**: being a plain text format you can read and edit it using any editor
- **Custom symbols**: you can replace the default symbols with any of the supported ones
- **Box**: `-` `` `` `` `` `` `` `` `` `` `` `` `` `` `[]` `[ ]`
- `NEW` **Started**: `` `` `` `o` `O` `[o]` `[O]`
- **Done**: `` `` `` `+` `[x]` `[X]` `[+]`
- **Cancelled**: `` `x` `X` `[-]`
- **Custom colors**: all colors can be customized
Expand Down Expand Up @@ -77,6 +78,7 @@ It adds 6 shortcuts when editing a `Todo` file:
"todo.symbols.box": "", // Box symbol
"todo.symbols.done": "", // Done symbol
"todo.symbols.cancelled": "", // Cancelled symbol
"todo.symbols.started": "", // Started symbol
"todo.colors.done": "#a6e22e", // Done todo color
"todo.colors.cancelled": "#f92672", // Cancelled todo color
"todo.colors.code": "#fd971f", // Code color
Expand Down Expand Up @@ -171,6 +173,7 @@ The following tokens can be used in `todo.statistics.project.text`, `todo.statis
| `[projects]` | Number of projects |
| `[tags]` | Number of tags |
| `[pending]` | Number of pending todos |
| `[doing]` | Number of doing/on progress todos |
| `[done]` | Number of done todos |
| `[cancelled]` | Number of cancelled todos |
| `[finished]` | Number of finished todos |
Expand Down
27 changes: 24 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
"description": "Todo cancelled string",
"default": ""
},
"todo.symbols.started": {
"type": "string",
"description": "Todo started string",
"default": ""
},
"todo.colors.done": {
"type": "string",
"description": "Done todo color",
Expand All @@ -138,6 +143,11 @@
"description": "Cancelled todo color",
"default": "#f92672"
},
"todo.colors.started": {
"type": "string",
"description": "Started todo color",
"default": "#FF9EFB"
},
"todo.colors.code": {
"type": "string",
"description": "Code color",
Expand Down Expand Up @@ -217,6 +227,9 @@
"cancelled": {
"type": "string"
},
"started": {
"type": "string"
},
"code": {
"type": "string"
},
Expand Down Expand Up @@ -259,6 +272,9 @@
"cancelled": {
"type": "string"
},
"started": {
"type": "string"
},
"code": {
"type": "string"
},
Expand Down Expand Up @@ -359,6 +375,11 @@
"description": "Format used for displaying time inside @created",
"default": "YY-MM-DD HH:mm"
},
"todo.timekeeping.started.enabled": {
"type": "boolean",
"description": "Enable the @started tag",
"default": true
},
"todo.timekeeping.started.time": {
"type": "boolean",
"description": "Insert the time inside the @started tag",
Expand Down Expand Up @@ -493,7 +514,7 @@
"todo.statistics.statusbar.tooltip": {
"type": "string",
"description": "Template used for rendering the tooltip",
"default": "[pending] Pending - [done] Done - [cancelled] Cancelled"
"default": "[pending] Pending - [doing] Doing - [done] Done - [cancelled] Cancelled"
},
"todo.embedded.regex": {
"type": "string",
Expand Down Expand Up @@ -1055,7 +1076,7 @@
"ts-loader": "^5.2.1",
"typescript": "^2.8.0",
"vscode": "^1.1.21",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2"
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12"
}
}
14 changes: 7 additions & 7 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import * as path from 'path';
import * as vscode from 'vscode';
import Config from './config';
import Consts from './consts';
import Document from './todo/document';
import ItemFile from './views/items/item';
import ItemTodo from './views/items/todo';
import StatusbarTimer from './statusbars/timer';
import Document from './todo/document';
import Utils from './utils';
import ViewEmbedded from './views/embedded';
import ViewFiles from './views/files';
import ItemFile from './views/items/item';
import ItemTodo from './views/items/todo';

/* CALL TODOS METHOD */

Expand Down Expand Up @@ -152,11 +152,11 @@ function toggleStart () {

return callTodosMethod ({
checkValidity: true,
filter: todo => todo.isBox (),
filter: todo => todo.isBox () || ! todo.isFinished (),
method: 'toggleStart',
errors: {
invalid: 'Only todos can be started',
filtered: 'Only not done/cancelled todos can be started'
filtered: 'Only not done/cancelled todos can be started/unstarted'
}
});

Expand Down Expand Up @@ -283,5 +283,5 @@ function viewEmbeddedShowActiveFile () {

/* EXPORT */

export {open, openEmbedded, toggleBox, toggleDone, toggleCancelled, toggleStart, toggleTimer, archive, viewOpenFile, viewRevealTodo, viewFilesOpen, viewFilesCollapse, viewFilesExpand, viewEmbeddedCollapse, viewEmbeddedExpand, viewEmbeddedFilter, embeddedFilter, viewEmbeddedClearFilter, embeddedClearFilter, viewEmbeddedToggleAllFiles, viewEmbeddedShowAllFiles, viewEmbeddedShowActiveFile};
export {toggleBox as editorToggleBox, toggleDone as editorToggleDone, toggleCancelled as editorToggleCancelled, toggleStart as editorToggleStart, archive as editorArchive}
export { open, openEmbedded, toggleBox, toggleDone, toggleCancelled, toggleStart, toggleTimer, archive, viewOpenFile, viewRevealTodo, viewFilesOpen, viewFilesCollapse, viewFilesExpand, viewEmbeddedCollapse, viewEmbeddedExpand, viewEmbeddedFilter, embeddedFilter, viewEmbeddedClearFilter, embeddedClearFilter, viewEmbeddedToggleAllFiles, viewEmbeddedShowAllFiles, viewEmbeddedShowActiveFile };
export { toggleBox as editorToggleBox, toggleDone as editorToggleDone, toggleCancelled as editorToggleCancelled, toggleStart as editorToggleStart, archive as editorArchive };
14 changes: 8 additions & 6 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const Consts = {
return {
done: _.get ( config, `${root}.done` ),
cancelled: _.get ( config, `${root}.cancelled` ),
started: _.get ( config, `${root}.started` ),
code: _.get ( config, `${root}.code` ),
comment: _.get ( config, `${root}.comment` ),
project: _.get ( config, `${root}.project` ),
Expand All @@ -40,6 +41,7 @@ const Consts = {
box: _.get ( config, 'symbols.box' ),
done: _.get ( config, 'symbols.done' ),
cancelled: _.get ( config, 'symbols.cancelled' ),
started: _.get ( config, 'symbols.started' ),
tag: '@'
},
colors: _.extend ( getColors ( 'colors' ), {
Expand All @@ -52,18 +54,18 @@ const Consts = {
regexes: {
impossible: /(?=a)b/gm,
empty: /^\s*$/,
todo: /^[^\S\n]*((?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\[[ xX+-]?\])\s[^\n]*)/gm,
todoSymbol: /^[^\S\n]*(?!--|––|——)([-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\[[ xX+-]?\])\s/,
todo: /^[^\S\n]*((?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\[[ xX+-oO]?\])\s[^\n]*)/gm,
todoSymbol: /^[^\S\n]*(?!--|––|——)([-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\[[ xX+-oO]?\])\s/,
todoBox: /^[^\S\n]*((?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s(?![^\n]*[^a-zA-Z0-9]@(?:done|cancelled)(?:(?:\([^)]*\))|(?![a-zA-Z])))[^\n]*)/gm,
todoBoxStarted: /^[^\S\n]*((?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s(?=[^\n]*[^a-zA-Z0-9]@started(?:(?:\([^)]*\))|(?![a-zA-Z])))[^\n]*)/gm,
todoBoxStarted: /^[^\S\n]*((?!--|––|——)(?:(?:(?:[⭘⭕◯oO]|\[[oO]\])\s[^\n]*)|(?:(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s[^\n]*[^a-zA-Z0-9]@started(?:(?:\([^)]*\))|(?![a-zA-Z]))[^\n]*)))/gm,
todoDone: /^[^\S\n]*((?!--|––|——)(?:(?:(?:[✔✓☑+]|\[[xX+]\])\s[^\n]*)|(?:(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s[^\n]*[^a-zA-Z0-9]@done(?:(?:\([^)]*\))|(?![a-zA-Z]))[^\n]*)))/gm,
todoCancelled: /^[^\S\n]*((?!--|––|——)(?:(?:(?:[✘xX]|\[-\])\s[^\n]*)|(?:(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s[^\n]*[^a-zA-Z0-9]@cancelled(?:(?:\([^)]*\))|(?![a-zA-Z]))[^\n]*)))/gm,
todoFinished: /^[^\S\n]*((?!--|––|——)(?:(?:(?:[✔✓☑+✘xX]|\[[xX+-]\])\s[^\n]*)|(?:(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s[^\n]*[^a-zA-Z0-9]@(?:done|cancelled)(?:(?:\([^)]*\))|(?![a-zA-Z]))[^\n]*)))/gm,
todoEmbedded: new RegExp ( _.get ( config, 'embedded.regex' ), _.get ( config, 'embedded.regexFlags' ) ),
project: /^(?![^\S\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\[[ xX+-]?\])\s[^\n]*)[^\S\n]*(.+:)[^\S\n]*(?:(?=@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)|$)/gm,
project: /^(?![^\S\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\[[ xX+-oO]?\])\s[^\n]*)[^\S\n]*(.+:)[^\S\n]*(?:(?=@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)|$)/gm,
projectParts: /(\s*)(.+):(.*)/,
archive: new RegExp ( `^(?![^\\S\\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\\[[ xX+-]?\\])\\s[^\\n]*)([^\\S\\n]*${_.escapeRegExp ( archiveName )}:.*$)`, 'gm' ),
comment: /^(?!\s*$)(?![^\S\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\[[ xX+-]?\])\s[^\n]*)(?![^\S\n]*.+:[^\S\n]*(?:(?=@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)|$))[^\S\n]*([^\n]+)/gm,
archive: new RegExp ( `^(?![^\\S\\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\\[[ xX+-oO]?\\])\\s[^\\n]*)([^\\S\\n]*${_.escapeRegExp ( archiveName )}:.*$)`, 'gm' ),
comment: /^(?!\s*$)(?![^\S\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\[[ xX+-oO]?\])\s[^\n]*)(?![^\S\n]*.+:[^\S\n]*(?:(?=@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)|$))[^\S\n]*([^\n]+)/gm,
tag: /(?:^|[^a-zA-Z0-9`])(@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)/gm,
tagSpecial: new RegExp ( `(?:^|[^a-zA-Z0-9])@(${tagsNames.map ( n => _.escapeRegExp ( n ) ).join ( '|' )})(?:(?:\\([^)]*\\))|(?![a-zA-Z]))`, 'gm' ),
tagSpecialNormal: new RegExp ( `(?:^|[^a-zA-Z0-9])(?:${tagsNames.map ( n => `(@${_.escapeRegExp ( n )}(?:(?:\\([^)]*\\))|(?![a-zA-Z])))` ).join ( '|' )}|(@[^\\s*~(]+(?::\/\/[^\\s*~(:]+)?(?:(?:\\([^)]*\\))|(?![a-zA-Z]))))`, 'gm' ),
Expand Down
7 changes: 5 additions & 2 deletions src/todo/decorators/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Project from './project';
import Tag from './tag';
import TodoDone from './todo_done';
import TodoCancelled from './todo_cancelled';
import TodoStarted from './todo_started';

/* DOCUMENTS LINES CACHE */

Expand Down Expand Up @@ -166,7 +167,8 @@ const Document = {
tags: doc.getTags (),
todosBox: doc.getTodosBox (),
todosDone: doc.getTodosDone (),
todosCancelled: doc.getTodosCancelled ()
todosCancelled: doc.getTodosCancelled (),
todosStarted: doc.getTodosStarted ()
};

},
Expand All @@ -179,7 +181,8 @@ const Document = {
new Tag ().getDecorations ( items.tags ),
new Project ().getDecorations ( items.projects ),
new TodoDone ().getDecorations ( items.todosDone ),
new TodoCancelled ().getDecorations ( items.todosCancelled )
new TodoCancelled ().getDecorations ( items.todosCancelled ),
new TodoStarted ().getDecorations ( items.todosStarted )
);

}
Expand Down
42 changes: 42 additions & 0 deletions src/todo/decorators/todo_started.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* IMPORT */

import * as vscode from "vscode";
import Consts from "../../consts";
import TodoStartedItem from "../items/todo_started";
import Line from "./line";

/* DECORATION TYPES */

const TODO_STARTED = vscode.window.createTextEditorDecorationType({
color: Consts.colors.started,
rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen,
dark: {
color: Consts.colors.dark.started,
},
light: {
color: Consts.colors.light.started,
},
});

/* TODO DONE */

class TodoStarted extends Line {
TYPES = [TODO_STARTED];

getItemRanges(
todoStarted: TodoStartedItem,
negRange?: vscode.Range | vscode.Range[]
) {
return [
this.getRangeDifference(
todoStarted.text,
todoStarted.range,
negRange || [Consts.regexes.tag, Consts.regexes.formattedCode]
),
];
}
}

/* EXPORT */

export default TodoStarted;
16 changes: 11 additions & 5 deletions src/todo/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import stringMatches from 'string-matches';
import * as vscode from 'vscode';
import Consts from '../consts';
import Utils from '../utils';
import {Line, Archive, Comment, Formatted, Project, Tag, Todo, TodoBox, TodoFinished, TodoDone, TodoCancelled} from './items';
import {Line, Archive, Comment, Formatted, Project, Tag, Todo, TodoBox, TodoFinished, TodoDone, TodoCancelled, TodoStarted} from './items';

/* DOCUMENT */

Expand Down Expand Up @@ -42,7 +42,7 @@ class Document {

/* GET */

getItems ( Item: typeof Line | typeof Archive | typeof Comment | typeof Formatted | typeof Project | typeof Tag | typeof Todo | typeof TodoBox | typeof TodoFinished | typeof TodoDone | typeof TodoCancelled, regex: RegExp ) {
getItems ( Item: typeof Line | typeof Archive | typeof Comment | typeof Formatted | typeof Project | typeof Tag | typeof Todo | typeof TodoBox | typeof TodoFinished | typeof TodoDone | typeof TodoCancelled | typeof TodoStarted, regex: RegExp ) {

const matchText = _.isString ( this.text ) ? this.text : this.textDocument.getText (),
matches = stringMatches ( matchText, regex );
Expand All @@ -53,7 +53,7 @@ class Document {

}

getItemAt ( Item: typeof Line | typeof Archive | typeof Comment | typeof Formatted | typeof Project | typeof Tag | typeof Todo | typeof TodoBox | typeof TodoFinished | typeof TodoDone | typeof TodoCancelled, lineNumber: number, checkValidity = true ) {
getItemAt ( Item: typeof Line | typeof Archive | typeof Comment | typeof Formatted | typeof Project | typeof Tag | typeof Todo | typeof TodoBox | typeof TodoFinished | typeof TodoDone | typeof TodoCancelled | typeof TodoStarted, lineNumber: number, checkValidity = true ) {

const line = this.textDocument.lineAt ( lineNumber );

Expand Down Expand Up @@ -141,12 +141,18 @@ class Document {

}

getTodosBoxStarted () {
getTodosStarted () {

return this.getItems ( TodoBox, Consts.regexes.todoBoxStarted );
return this.getItems ( TodoStarted, Consts.regexes.todoBoxStarted );

}

getTodosStartedAt ( lineNumber: number, checkValidity? ) {

return this.getItemAt ( TodoStarted, lineNumber, checkValidity );

}

getTodosDone () {

return this.getItems ( TodoDone, Consts.regexes.todoDone );
Expand Down
3 changes: 2 additions & 1 deletion src/todo/items/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import TodoBox from './todo_box';
import TodoFinished from './todo_finished';
import TodoDone from './todo_done';
import TodoCancelled from './todo_cancelled';
import TodoStarted from './todo_started';

/* EXPORT */

export {Archive, Comment, Formatted, Item, Line, Project, Tag, Todo, TodoBox, TodoFinished, TodoDone, TodoCancelled};
export {Archive, Comment, Formatted, Item, Line, Project, Tag, Todo, TodoBox, TodoFinished, TodoDone, TodoCancelled, TodoStarted};
Loading

0 comments on commit db227e0

Please sign in to comment.