1 // This file is part of a terminal todo application.
3 // Copyright (C) 2006 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
9 #ifndef CLDOC_H_0C4B8F6A2D8E432948411FC661E0CABB
10 #define CLDOC_H_0C4B8F6A2D8E432948411FC661E0CABB
14 /// \class CCurlistDocument cldoc.h cldoc.h
15 class CCurlistDocument
: public CDocument
{
17 typedef const tdevec_t
& rctdevec_t
;
18 typedef const CTodoItem
& rcitem_t
;
19 typedef CTodoItem::id_t itemid_t
;
20 typedef const string
& rcfname_t
;
22 f_CompleteVisible
= CDocument::f_Last
, ///< All old items are visible.
23 f_Descended
, ///< Descended down item tree by dir path.
27 CCurlistDocument (void);
28 rcitem_t
CurrentItem (void) const;
29 inline uint32_t Selection (void) const { return (m_Selection
.back()); }
30 inline rctdevec_t
List (void) const { return (m_List
); }
31 void SetSelection (uoff_t v
);
32 void AppendItem (void);
33 void PasteLinkToItem (itemid_t id
);
34 void UpdateCurrentItem (rcitem_t e
);
35 void RemoveCurrentItem (void);
37 inline void ToggleCompleteVisible (void) { SetFlag (f_CompleteVisible
, !Flag (f_CompleteVisible
)); ReloadList(); }
38 inline size_t NestingDepth (void) const { return (m_Stack
.size() - 1); }
39 void SetCurrentItemPriority (CTodoItem::EPriority p
);
40 void MarkItemComplete (void);
41 void EnterCurrentItem (void);
42 void LeaveCurrentItem (void);
44 virtual void OnUpdate (void);
45 virtual void OnInitialUpdate (void);
46 virtual void OnCommand (cmd_t c
);
47 virtual void OnUpdateCommandUI (rcmd_t rc
) const;
49 typedef CTodoDocument
* pdoc_t
;
50 typedef const CTodoDocument
* pcdoc_t
;
51 typedef tdevec_t::iterator iitem_t
;
52 typedef tdevec_t::const_iterator icitem_t
;
53 typedef tddepmap_t::iterator idep_t
;
54 typedef tddepmap_t::const_iterator icdep_t
;
55 typedef const tddepmap_t
& rcdepmap_t
;
56 typedef vector
<itemid_t
> itstack_t
;
57 typedef vector
<uint32_t> selstack_t
;
59 inline pdoc_t
Document (void) { return (TDocument
<CTodoDocument
>()); }
60 inline pcdoc_t
Document (void) const { return (TDocument
<CTodoDocument
>()); }
61 inline rcdepmap_t
Deps (void) const { return (m_Deps
); }
62 void DescendByCwd (void);
63 bool ItemNameIsADirectory (rcfname_t name
) const;
64 void UpdateItemDirectoryFlag (iitem_t icuri
) const;
65 void ReloadList (void);
66 void SelectItem (itemid_t id
);
67 inline itemid_t
ItemId (void) const { return (m_Stack
.back()); }
68 rcfname_t
GetTodoFileDir (void) const;
70 tdevec_t m_List
; ///< Currently selected list.
71 tddepmap_t m_Deps
; ///< Dependency list that created m_List.
72 itstack_t m_Stack
; ///< The callstack of the currently active list.
73 selstack_t m_Selection
; ///< Index of the selected item.
76 //----------------------------------------------------------------------
78 /// Global commands for this application.
92 cmd_Item_Priority_Highest
,
93 cmd_Item_Priority_High
,
94 cmd_Item_Priority_Medium
,
95 cmd_Item_Priority_Low
,
96 cmd_Item_Priority_Lowest
,
99 //----------------------------------------------------------------------