├── .github └── FUNDING.yml ├── .gitignore ├── Documentation.md ├── FILES.md ├── LICENSE ├── README.md ├── __init__.py ├── changeFunction.py ├── column.py ├── config.json ├── config.md ├── config.py ├── config.schema.json ├── consts.py ├── counts.md ├── debug.py ├── deckbrowser.js ├── defaultcss.css ├── example.png ├── htmlAndCss.py ├── node.py ├── printing.py ├── strings.py ├── tree.py └── zipping /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: ArthurMilchior 4 | ko_fi: arthurmilchior 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | i 103 | /enhanced_main.py~ 104 | /enhancedMain.py~ 105 | *~ 106 | /meta.json 107 | *zip 108 | *# 109 | /config.gui 110 | -------------------------------------------------------------------------------- /Documentation.md: -------------------------------------------------------------------------------- 1 | This file explains how this add-on works. 2 | 3 | # Files 4 | ## ChangeFunction 5 | This file is in charge of monkey-patching each function which must be 6 | monkey patched. 7 | 8 | ## Config 9 | This file is in charge of reading user's configuration. It is also updated 10 | if an outdated configuration file is found. 11 | 12 | ## Debug 13 | Function which helps debugging. Normally, mayDebug and shouldDebug 14 | must be False in the code distributed, and thus no debugging occurs. 15 | 16 | ## Html 17 | Contains all of the HTML which is used to generate the list of decks in 18 | the main window. The HTML is either contained in a string variable if 19 | it does not change, or in a small function which takes a parameter and 20 | returns the HTML string. 21 | 22 | ## Strings 23 | This associates to each column some strings describing it: a short one 24 | used in the header of the column, and a longer one used in the overlay 25 | describing the number. 26 | 27 | ## Tree 28 | Contains functions used to compute global information, e.g. how 29 | many cards there are of each kind in each deck (not considering the 30 | subdeck), and how much time to wait before the next review. 31 | 32 | It's computed globally because it allows a single query instead 33 | of having to do one query per deck. 34 | 35 | ## Node 36 | Globally, it contains everything else. It contains each computation 37 | which must be done recursively on a deck by deck basis, and the 38 | function to print each deck. 39 | -------------------------------------------------------------------------------- /FILES.md: -------------------------------------------------------------------------------- 1 | * changeFunction: ensure that Anki's methods are changed by the new one 2 | * column: from HTML to configuration, deleting/moving column 3 | * config: allow to access and update config 4 | * htmlAndCss: constants and methods allowing to CSS and HTML to be 5 | entered in the deckBrowser 6 | * node: compute the values associated with each deck, taking subdecks into 7 | account 8 | * printing: method to compute the strings shown to the user 9 | * strings: dictionaries associating to each name the column's header 10 | and description 11 | * Computing the set of values associated with each card 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # anki-enhance-main-window 2 | Adds a lot of features to the main window. Allows configuration of those features. Configurations are explained at the end of this document. 3 | 4 | 5 | Important updates: 6 | * 5th of June 2019: A column for flags, and columns for each flag 7 | * 30th of March 2019: column can be dragged and dropped, and use right click to delete. 8 | * 12 February 2019: default colors are changed to use the color of the statistic window. 9 | * 11 February 2019: percent bar 10 | * February: counting the number of reviews, today and any time in the past, and the number of cards seen today. 11 | * 19th January 2019: many bugs corrected. Configuration can be changed without restarting Anki. 12 | * 8th November 2018: you can configure the add-on using anki 2.1's 13 | configuration method. The configuration won't be lost during next update of the add-on ! 14 | 15 | ![Example](example.png) 16 | 17 | # Features 18 | ## Column 19 | Most features offered by this add-on are related to some column. 20 | 21 | You can change the order of the columns by dragging their name and dropping them at their new position. 22 | ### Name of the (sub)deck 23 | There is not a lot of change in this column, apart from the decks's color. 24 | #### Empty decks 25 | If a (sub)deck is empty, it turns red. (You can configure the color.) 26 | 27 | This may not be useful for everybody. But if you want to know when a deck is empty in order to add new notes in it, it avoids having to check the number of new cards for each deck. For example, if you want to learn guitar chords, it will let you know that it is time to add new chords to Anki. 28 | 29 | Whats even better ! If you use subdecks, the ancestors (parent) of an empty subdeck become blue (also configurable). This allows you to find decks with an empty subdeck. Hence, it helps finding empty subdecks without having to expand every top-level deck. 30 | 31 | Note that, in some cases, you don't want the name to become red, e.g. you wanted to learn the name of the Greek letters. When you know all of them, you won't add any new note ever. You just have to add a semicolon (;) (that is configurable) to the name of the deck, and it will not turn red. 32 | #### Marked cards 33 | Decks with marked card have a blue background (configurable). Furthermore, if the deck's name contains a semicolon (i.e. as explained above, the deck is ended), then the background become yellow. 34 | 35 | ### Learning 36 | The number of reviews of cards in learning. By default you will see the number of reviews that can be done now, and in parentheses the number of reviews which can be done later today. 37 | 38 | ### Review 39 | The number of cards which you have seen in the past, and that you should see today. By default, the number of cards you will see today. And in parentheses the number of cards you should see today, but that you will not see today because of your limit. 40 | 41 | ### New today 42 | This column called new in Anki. New means «number of new cards you will see today», with the caveat that it is not exactly true for subdecks. 43 | 44 | ### New 45 | The column name "new" is deprecated. It is kept for backwards compatibility, but may be removed one day. It is the same thing as New Today. 46 | 47 | ### Due 48 | By default, this column is hidden. Indeed, it became two columns «due now» and «later». We recall that, in Anki, a due card is a card which is not new, and that you have to view again today. 49 | 50 | ### Unseen 51 | The number of cards which you have never answered. Most of these cards are cards you have never seen, but it also considers cards you have seen and buried. By default, the number of unseen cards which you will discover today, and in parentheses the number of unseen cards you will not see today. 52 | 53 | ### Young 54 | The number of cards whose interval is less than 3 weeks 55 | 56 | ### Mature 57 | The number of cards whose interval is at least 3 weeks 58 | 59 | ### Buried 60 | The number of Buried cards. Keep in mind that a buried card is a card you will not see today, either because you pressed the «bury» button, or because you saw another card from the same note, so it was automatically buried. 61 | 62 | ### Suspended 63 | The number of Suspended cards. Keep in mind that a suspended card is a card you will never see again, unless you unsuspend it manually (using the browser). 64 | 65 | ### Total 66 | The number of cards in this deck. It is not the sum of the preceding column, since it contains also cards you have already seen and which are not yet due (and it counts a card with multiple reviews once). 67 | 68 | ### Today 69 | The total number of reviews you will see today (assuming you always rate good). 70 | 71 | ### Configuration 72 | The last column states which options group is used for the current deck. This avoids the pain of opening the menu to see the option names. Really useful when you have a lot of decks and want to see which is the last deck which used this old configuration you want to delete. 73 | 74 | ## Capping 75 | By default, Anki does not show any number greater than 1000. Instead it shows 1000+. 76 | You can now edit this limit, or remove it entirely (by using a negative number). If you set the limit to 0, you will either see a 0, or "+". 77 | 78 | 79 | How to configure this add-on 80 | =========================== 81 | Most options are configurable. If some option is not configurable, send me an email and I'll see what I can do. 82 | 83 | In order to configure this add-on (hence, to configure what is shown in the main window), go to Tools>add-ons>[name of this add-on]>Config. You'll see the configuration file. It will also display in a small window a display of the configuration's rule. We copy them below 84 | 85 | # Configuration file 86 | 87 | 88 | # Configuration of Anki's addon Enhanced Main 89 | 1. We first discuss the various small configurations related to the whole add-on. 90 | 1. We then explain how to configure each column. 91 | 1. We then explain how to configure coloring related to empty deck. 92 | 1. We finally explain how to configure coloring related to marked cards. 93 | 94 | ## Miscelaneous 95 | In this section, we describe various small configurations related to 96 | the whole add-on. 97 | 98 | ### CSS 99 | If the value is `null` then the default css is used. Otherwise, you can put the CSS you want here. Use the add-on [Newline in strings in add-ons configurations](https://ankiweb.net/shared/info/112201952) if you want to use newline in JSON/CSS string. 100 | 101 | ### Refresh rate 102 | How much time to wait between refreshing the main window. In seconds. By default, the window is refreshed every 30 seconds, thus, it is possible that change made less than half a minute ago are not yet shown. 103 | 104 | ### Option 105 | Whether you want to display the deck's Option group's name, at the end of its line. 106 | 107 | ### cap value 108 | By default, without add-on, Anki never shows number greater than a thousand. Instead, it shows 1000+. You can decide to change a thousand by an arbitrary number. Or leave this value to null, and always show the real value. 109 | 110 | Note that capping to a thousand does not usually make the rendering quicker. 111 | 112 | ## Columns 113 | 114 | Each column should occur after the line "columns" :[, and before the line with a closing bracket ]. The order of the lines is important, since it's the order in which columns will be displayed by anki. This order can also be changed by dragging and dropping the column title. This means that you can reorder columns in anki by reordering the lines in the configuration. You can copy a line to display a column multiple time (for example, once using percent, and another time using absolute number). 115 | 116 | Each column is represented between an opening curly bracket {, and a closing curly bracket }. Each column uses 8 parameters, each represented as a pair `key:value`. We'll tell you the meaning of each key, whether you can change its value, and what will this change do. 117 | 118 | ### Name 119 | The first value is a description, which will tell you what the column represent. Do NOT alter this value, or the add-on will raise an error. 120 | 121 | ### Description 122 | A description of the content of the column. This is not used by anki, it allows you to decide whether you want the column or not while you edit the configuration. 123 | 124 | ### Present 125 | The value for the key "present" is either true or false. If the value is true, the column will be displayed. Otherwise, it will not. Note that you can also delete the entire column from the configuration, instead of changing the value to false. 126 | 127 | If this value is absent, by default, it is assumed that it should be true. 128 | 129 | ### Header 130 | The header of the column. If you leave «null» then the default header will be used. This description will be translated as much as it is possible to do it automatically. However, you can also choose to write your own description. You can use html in this description. I.e. you should use "
" when you want a newline. 131 | 132 | ### Overlay 133 | The text shown when your mouse is over a number. It will describe what this number represent. You can remove this key if you want no description to be present. And leave this value to null if you want to use the default value. 134 | 135 | ### Color 136 | The color in which the number is shown in this column. You can use any color acceptable in an HTML document. The most standard color's name should work. 137 | 138 | ### Percent 139 | true or false whether you want to show the percent of cards satisfying this column condition. For example, 23% of cards are new. Note that sometimes, this would not make sense. For example, for the column «cards», the value will always be 100% (unless the deck is empty). For the column notes, the number would not really make any sens (formally, you'd get the percent of cards which is the first of its sibling in this deck). 140 | 141 | By default, percent is assumed to be false if absent. 142 | 143 | ### Absolute 144 | Whether you want an absolute number in your column or not. That is, a number which is not a percent, but an exact number. 145 | 146 | By default, this value is false if Percent is set to true, otherwise its default value is true. 147 | 148 | ### Subdecks 149 | When you consider a deck which has subdecks, you may want to consider cards in subdecks (it is done when the value is true), or you may want to ignore them (it is done when the value is false). 150 | 151 | ## Percent Bar 152 | If the name is "bar", instead of a number, the column contain a percent bar. 153 | 154 | In this case, the configuration of this column must contain a field "names", whose value is a list of name. The names are the same name than for columns. It uses the same color and overlay. 155 | 156 | ## Coloring decks 157 | The author of this add-on want to know when a deck is empty. This is very important to him, because he want to add new cards in them as soon as possible. Thus, this add-on change the color of the name of empty decks, and of name of decks with an empty descendant. 158 | 159 | The author also want to know which deck has marked card. Thus, the background of the deck's name with marked card change color. 160 | 161 | Both of those configuration can be changed as explained in this section. In particular, you can turn one or both of those options off by setting "color empty" and "color marked" to false. 162 | ### Choice of color 163 | #### Color empty 164 | The color of the name of decks without new cards 165 | 166 | #### Color empty descendant 167 | The color of the name of decks with a descendant without new cards 168 | 169 | #### Default color 170 | The color of a deck whose every descendant has new cards. 171 | 172 | #### ended marked background color 173 | The color of the decks which has an ended deck with marked cards. The notion of ended deck will be explained in the next section of this documentation. 174 | 175 | #### marked background color 176 | The color of deck who have marked cards but none of its descendant are both ended and has marked card. 177 | 178 | ### Deck modifier 179 | A deck modifier is a symbol (or a word, etc..) whose presence in a deck name change the meaning of the deck. When the meaning is changed, the coloration is also change. It's not clear to the author of this add-on whether anyone appart from himself will need those, but if you want to use them, here is the explanation. 180 | 181 | The first three symbols currently has the same effect, but it may occur that one day this effect may change, according of what the author want to do. 182 | #### End symbol 183 | By default, this symbol is ";". It means that the deck is definitively done, and no new card may ever be added to it. When a deck has this symbol, neither itself nor its descendant will ever be colored. 184 | 185 | #### Given up symbol 186 | By default, this symbol is "/".To the author, it means that no new card will be added because this deck is either too hard, or not interesting enough. 187 | 188 | #### Pause symbol" 189 | By default, this symbol is "=". To the author, it means that more new card will be added latter, but right now it does not want anki to change the color of the deck's name. In a future version, there may be an option to change the color of those decks. 190 | 191 | ## Internals 192 | * In `aqt.deckbrowser`, change `DeckBrowser._renderDeckTree`, `DeckBrowser.refresh` and `DeckBrowser._deckRow`. The former methods are not called. 193 | * In `Anki.notes`, change `Note.flush`. The new method calls the former one. 194 | * In `anki.decks` change `DeckManager.save`, calling the former method. Changing `DeckManager.collaps`, not calling the former method. 195 | 196 | ## Documentation for developpers 197 | See [Documentation.md](Documentation.md) 198 | 199 | ## Links, licence and credits 200 | 201 | Key |Value 202 | -------------|------------------------------------------------------------------- 203 | Copyright |Arthur Milchior 204 | Based on |Anki code by Damien Elmes 205 | Based on |Helen Foster's code, in add-on "Deck_Counts_Now_Later" 206 | Original idea|Juda Kaleta 207 | Somme CSS |Some idea from cjdduarte 208 | Bug correction|telotortium on Github 209 | Percent bar | Idea and partial realization by Kyle "Khonkhortisan" Mills 210 | License |GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html 211 | Source in | https://github.com/Arthur-Milchior/anki-enhance-main-window 212 | Addon number | [877182321](https://ankiweb.net/shared/info/877182321) 213 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | from . import changeFunction 2 | -------------------------------------------------------------------------------- /changeFunction.py: -------------------------------------------------------------------------------- 1 | from anki.decks import DeckManager 2 | from anki.notes import Note 3 | try: 4 | from anki.sched import Scheduler 5 | except ModuleNotFoundError: 6 | from anki.scheduler import v3 7 | from aqt.deckbrowser import DeckBrowser 8 | 9 | from .column import _linkHandler 10 | from .debug import debug 11 | from .node import idToNode, renderDeckTree 12 | 13 | 14 | # based on Anki 2.0.36 aqt/deckbrowser.py DeckBrowser._deckRow 15 | def deckRow(self, node, depth, cnt): 16 | return node.htmlRow(self, depth, cnt) 17 | 18 | 19 | DeckBrowser._deckRow = deckRow 20 | 21 | DeckBrowser._renderDeckTree = renderDeckTree 22 | 23 | DeckBrowser._linkHandler = _linkHandler 24 | -------------------------------------------------------------------------------- /column.py: -------------------------------------------------------------------------------- 1 | from anki.lang import _ 2 | from aqt.deckbrowser import DeckBrowser 3 | from aqt.qt import * 4 | from aqt.utils import askUser 5 | 6 | from .config import getUserOption, writeConfig 7 | 8 | lastHandler = DeckBrowser._linkHandler 9 | 10 | 11 | def _linkHandler(self, url): 12 | if ":" in url: 13 | (cmd, arg) = url.split(":") 14 | if cmd == "dragColumn": 15 | return columnHandler(self, arg) 16 | elif cmd == "optsColumn": 17 | return columnOptions(self, arg) 18 | return lastHandler(self, url) 19 | 20 | 21 | def columnHandler(self, arg): 22 | draggedDeckId, ontoDeckId = arg.split(",") 23 | draggedDeckId = int(draggedDeckId) 24 | ontoDeckId = int(ontoDeckId) 25 | columns = getUserOption("columns") 26 | columns.insert(draggedDeckId, columns.pop(ontoDeckId)) 27 | writeConfig() 28 | self.show() 29 | 30 | 31 | def columnOptions(self, colpos): 32 | m = QMenu(self.mw) 33 | a = m.addAction(_("Delete")) 34 | a.triggered.connect(lambda: deleteColumn(self, colpos)) 35 | m.exec_(QCursor.pos()) 36 | 37 | 38 | def deleteColumn(self, colpos): 39 | if not askUser(_("""Are you sure you wish to delete this column ?""")): 40 | return 41 | colpos = int(colpos) 42 | print("They are sure.") 43 | columns = getUserOption("columns") 44 | column = columns[colpos] 45 | column["present"] = False 46 | writeConfig() 47 | self.show() 48 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "columns" :[ 3 | { 4 | "description":"Number of reviews you will see today (new, review and learning)", 5 | "present":true, 6 | "name":"today", 7 | "header":null, 8 | "color":"red", 9 | "overlay":null, 10 | "absolute":true, 11 | "percent":false, 12 | "subdeck":true 13 | }, 14 | { 15 | "description":"Cards you'll see today which are not new", 16 | "present":false, 17 | "name":"cards seen today", 18 | "header":null, 19 | "color":"red", 20 | "overlay":null, 21 | "absolute":true, 22 | "percent":false, 23 | "subdeck":true 24 | }, 25 | { 26 | "description":"Cards in learning (either new cards you see again, or cards which you have forgotten recently, assuming those cards didn't graduate)", 27 | "present":false, 28 | "name":"learning card", 29 | "header":null, 30 | "color":null, 31 | "overlay":null, 32 | "absolute":true, 33 | "percent":false, 34 | "subdeck":true 35 | }, 36 | { 37 | "description":"Reviews which will happen later, either because a review happened recently, or because the card has many review left.", 38 | "present":false, 39 | "name":"learning later", 40 | "header":null, 41 | "color":null, 42 | "overlay":null, 43 | "absolute":true, 44 | "percent":false, 45 | "subdeck":true 46 | }, 47 | { 48 | "description":"Cards in learning which are due now (and in parentheses, the number of reviews which are due later)", 49 | "present":true, 50 | "name":"learning all", 51 | "header":null, 52 | "color":null, 53 | "overlay":null, 54 | "absolute":true, 55 | "percent":false, 56 | "subdeck":true 57 | }, 58 | { 59 | "description":"Cards in learning which are due now", 60 | "present":false, 61 | "name":"learning now", 62 | "header":null, 63 | "color":null, 64 | "overlay":null, 65 | "absolute":true, 66 | "percent":false, 67 | "subdeck":true 68 | }, 69 | 70 | { 71 | "description":"Review cards you will see today (and the ones you will not see today)", 72 | "present":true, 73 | "name":"review", 74 | "header":null, 75 | "color":"green", 76 | "overlay":null, 77 | "absolute":true, 78 | "percent":false, 79 | "subdeck":true 80 | }, 81 | { 82 | "description":"Review cards which are due today (not counting those in learning)", 83 | "present":false, 84 | "name":"review due", 85 | "header":null, 86 | "color":"green", 87 | "overlay":null, 88 | "absolute":true, 89 | "percent":false, 90 | "subdeck":true 91 | }, 92 | { 93 | "description":"Review cards you will see today", 94 | "present":false, 95 | "name":"review today", 96 | "header":null, 97 | "color":"green", 98 | "overlay":null, 99 | "absolute":true, 100 | "percent":false, 101 | "subdeck":true 102 | }, 103 | 104 | { 105 | "description":"Unseen cards you will see today (what Anki calls New cards), followed by the unseen cards that you will not see today. Neither buried nor suspended.", 106 | "present":true, 107 | "name":"unseen new", 108 | "header":null, 109 | "color":null, 110 | "overlay":null, 111 | "absolute":true, 112 | "percent":false, 113 | "subdeck":true 114 | }, 115 | { 116 | "description":"Cards that have never been answered. Neither buried nor suspended.", 117 | "present":false, 118 | "name":"unseen", 119 | "header":null, 120 | "color":null, 121 | "overlay":null, 122 | "absolute":true, 123 | "percent":false, 124 | "subdeck":true 125 | }, 126 | { 127 | "description":"Unseen cards you will see today (what Anki calls New cards). Neither buried nor suspended.", 128 | "present":false, 129 | "name":"new today", 130 | "header":null, 131 | "color":null, 132 | "overlay":null, 133 | "absolute":true, 134 | "percent":false, 135 | "subdeck":true 136 | }, 137 | 138 | { 139 | "description":"Number of buried cards (cards you decided not to see today)/Number of suspended cards (cards you will never see unless you unsuspend them in the browser)", 140 | "present":true, 141 | "name":"buried/suspended", 142 | "header":null, 143 | "color":null, 144 | "overlay":null, 145 | "absolute":true, 146 | "percent":false, 147 | "subdeck":true 148 | }, 149 | { 150 | "description":"Number of buried cards (cards you decided not to see today, or you saw a sibling)", 151 | "present":false, 152 | "name":"buried", 153 | "header":null, 154 | "color":null, 155 | "overlay":null, 156 | "absolute":true, 157 | "percent":false, 158 | "subdeck":true 159 | }, 160 | { 161 | "description":"Number of suspended cards (cards you will never see unless you unsuspend them in the browser)", 162 | "present":false, 163 | "name":"suspended", 164 | "header":null, 165 | "color":null, 166 | "overlay":null, 167 | "absolute":true, 168 | "percent":false, 169 | "subdeck":true 170 | }, 171 | { 172 | "description":"Number of cards/notes in the deck", 173 | "present":true, 174 | "name":"notes/cards", 175 | "header":null, 176 | "color":"black", 177 | "overlay":null, 178 | "absolute":true, 179 | "percent":false, 180 | "subdeck":true 181 | }, 182 | { 183 | "description":"Number of cards in the deck", 184 | "present":false, 185 | "name":"cards", 186 | "header":null, 187 | "color":"black", 188 | "overlay":null, 189 | "absolute":true, 190 | "percent":false, 191 | "subdeck":true 192 | }, 193 | { 194 | "description":"Number of notes in the deck", 195 | "present":false, 196 | "name":"notes", 197 | "header":null, 198 | "color":"black", 199 | "overlay":null, 200 | "absolute":true, 201 | "percent":false, 202 | "subdeck":true 203 | }, 204 | { 205 | "description":"Number of reviewed cards with interval at least 3 weeks/less than 3 weeks", 206 | "present":true, 207 | "name":"mature/young", 208 | "header":null, 209 | "color":null, 210 | "overlay":null, 211 | "absolute":true, 212 | "percent":false, 213 | "subdeck":true 214 | }, 215 | { 216 | "description":"Number of reviewed cards which are not yet due", 217 | "present":false, 218 | "name":"undue", 219 | "header":null, 220 | "color":null, 221 | "overlay":null, 222 | "absolute":true, 223 | "percent":false, 224 | "subdeck":true 225 | }, 226 | { 227 | "description":"Number of reviewed cards with interval at least 3 weeks", 228 | "present":false, 229 | "name":"mature", 230 | "header":null, 231 | "color":null, 232 | "overlay":null, 233 | "absolute":true, 234 | "percent":false, 235 | "subdeck":true 236 | }, 237 | { 238 | "description":"Number of reviewed cards with interval less than 3 weeks", 239 | "present":false, 240 | "name":"young", 241 | "header":null, 242 | "color":null, 243 | "overlay":null, 244 | "absolute":true, 245 | "percent":false, 246 | "subdeck":true 247 | }, 248 | { 249 | "description":"Number of marked notes", 250 | "present":true, 251 | "name":"marked", 252 | "header":null, 253 | "color":"purple", 254 | "overlay":null, 255 | "absolute":true, 256 | "percent":true, 257 | "subdeck":true 258 | }, 259 | { 260 | "description":"Number of notes with a leech card", 261 | "present":false, 262 | "name":"leech", 263 | "header":null, 264 | "color":"purple", 265 | "overlay":null, 266 | "absolute":true, 267 | "percent":true, 268 | "subdeck":true 269 | }, 270 | { 271 | "description":"Number of reviewed cards seen today", 272 | "present":false, 273 | "name":"reviewed today", 274 | "header":null, 275 | "color":"magenta", 276 | "overlay":null, 277 | "absolute":true, 278 | "percent":false, 279 | "subdeck":true 280 | }, 281 | { 282 | "description":"Number of reviews done today", 283 | "present":false, 284 | "name":"repeated today", 285 | "header":null, 286 | "color":"magenta", 287 | "overlay":null, 288 | "absolute":true, 289 | "percent":false, 290 | "subdeck":true 291 | }, 292 | { 293 | "description":"Number of reviewed cards seen today and number of reviews", 294 | "present":true, 295 | "name":"reviewed today/repeated today", 296 | "header":null, 297 | "color":"magenta", 298 | "overlay":null, 299 | "absolute":true, 300 | "percent":false, 301 | "subdeck":true 302 | }, 303 | { 304 | "description":"Number of times you saw a question from this deck", 305 | "present":true, 306 | "name":"repeated", 307 | "header":null, 308 | "color":null, 309 | "overlay":null, 310 | "absolute":true, 311 | "percent":false, 312 | "subdeck":true 313 | }, 314 | { 315 | "present":true, 316 | "description": "Percent bar to do today", 317 | "header": "Today", 318 | "name": "bar", 319 | "names": ["review today", "learning card","new today", "reviewed today"], 320 | "overlay": null, 321 | "subdeck": true 322 | }, 323 | { 324 | "description": "Percent bar showing the decks' repartition", 325 | "present":true, 326 | "header": "Total", 327 | "name": "bar", 328 | "names": ["mature","young", "learning card", "unseen","buried", "suspended"], 329 | "overlay": null, 330 | "subdeck": true 331 | }, 332 | { 333 | "description":"Reviewed cards which are due tomorrow", 334 | "present":true, 335 | "name":"due tomorrow", 336 | "header":null, 337 | "color":"green", 338 | "overlay":null, 339 | "absolute":true, 340 | "percent":false, 341 | "subdeck":true 342 | }, 343 | { 344 | "description":"Flags from 0 to 4", 345 | "present":false, 346 | "name":"all flags", 347 | "header":"Flags", 348 | "color":null, 349 | "overlay":null, 350 | "absolute":true, 351 | "percent":false, 352 | "subdeck":true 353 | }, 354 | { 355 | "description":"Flags from 1 to 4", 356 | "present":true, 357 | "name":"flags", 358 | "header":"Flags", 359 | "color":null, 360 | "overlay":null, 361 | "absolute":true, 362 | "percent":false, 363 | "subdeck":true 364 | }, 365 | { 366 | "description":"Flag 1", 367 | "present":false, 368 | "name":"flag 1", 369 | "header":"Flag 1", 370 | "color":"Red", 371 | "overlay":null, 372 | "absolute":true, 373 | "percent":false, 374 | "subdeck":true 375 | } 376 | ], 377 | 378 | "hide values of parent decks": false, 379 | "hide values of parent decks when subdecks are shown": false, 380 | "default column color": "grey", 381 | "option" : true, 382 | "cap value" : null, 383 | "color empty" : "red", 384 | "color empty descendant" : "green", 385 | "marked background color" : "powderblue", 386 | "ended marked background color" : "yellow", 387 | "end symbol" : ";", 388 | "book symbol" : "{", 389 | "given up symbol" : "/", 390 | "pause symbol" : "=", 391 | "do color marked" : true, 392 | "do color empty" : true, 393 | "dot in numbers":true, 394 | "color zero": false 395 | } 396 | -------------------------------------------------------------------------------- /config.md: -------------------------------------------------------------------------------- 1 | # Configuration of Anki's addon Enhanced Main 2 | 3 | 1. We first discuss the various small configurations related to the whole add-on. 4 | 1. We then explain how to configure each column. 5 | 1. We then explain how to configure coloring related to empty decks. 6 | 1. We finally explain how to configure coloring related to marked cards. 7 | 8 | ## Miscelaneous 9 | In this section, we describe various small configurations related to the whole add-on. 10 | 11 | ### Option 12 | Whether you want to display the deck option's name at the end of its line. 13 | 14 | 15 | ### cap value 16 | By default, without an add-on, Anki never shows numbers greater than a thousand. Instead, it shows 1000+. You can decide to change the thousand to an arbitrary number, or leave this value to null which always show the real value. 17 | 18 | Note that capping to a thousand does not usually make the rendering quicker. 19 | 20 | ### Dot in number 21 | Whether you want a thousand separator for big numbers, such as 34968, to be shown as "34.968" or as "34968". 22 | 23 | ### hide values of parent decks 24 | If a deck has children, its number are not shown. 25 | 26 | ### hide values of parent decks when subdecks are shown 27 | Similar to last option, but it hides number only if the subdecks are shown. 28 | 29 | ### color zero 30 | The color to use for the zero. If it's a string, use always this color. By default in Anki, it's a kind of grey. If you set it to false (default in this add-on), then the zero is not shown at all. You can remove this line or set it to `null` to ensure that the default column is used. To obtain the grey which is the default value in Anki, you can set the color to "#e0e0e0". 31 | 32 | ## Columns 33 | 34 | Each column should occur after the line "columns" :[, and before the line with a closing bracket ]. The order of the lines is important, since it's the order in which columns will be displayed by Anki. This means that you can reorder columns in Anki by reordering the lines in the configuration. You can copy a line to display a column multiple times (for example, once using percent, and another time using absolute number). 35 | 36 | Each column is represented between an opening curly bracket {, and a closing curly bracket }. Each column uses 8 parameters, each represented as a pair. 37 | >>key:value 38 | We'll tell you the meaning of each key, whether you can change its value, and what this change will do. 39 | 40 | ### Name 41 | The first value is a description, which will tell you what the column represents. Do NOT alter this value, or the add-on will raise an error. 42 | 43 | ### Description 44 | A description of the content of the column. This is not used by Anki. It allows you to decide whether you want the column while you edit the configuration. 45 | 46 | 47 | ### Present 48 | The value for the key "present" is either true or false. If the value is set to true, the column will be displayed. Otherwise, it will not. Note that you can also delete the entire column from the configuration, instead of changing the value to false. 49 | 50 | If this value is absent, by default, it is assumed that it should be set to true. 51 | 52 | ### Header 53 | The header of the column. If you leave `null` then the default header will be used. This description will be translated as much as it is possible to do it automatically. However, you can also choose to write your own description. You can use HTML in this description. You should use "
" when you want a newline. 54 | 55 | ### Overlay 56 | The text shown when your mouse is over a number. It will describe what this number represents. You can set this key to false if you want no description to be present. And leave this value to `null` if you want to use the default value. 57 | 58 | ### Color 59 | The color in which the number is written in this column. You can use any color acceptable in an HTML document. Most standard color names should work. `null` means that it should use the same color as in the statistic window, if this color exists, or the default color otherwise. 60 | 61 | ### Percent 62 | true or false whether you want to show the percent of cards satisfying this column condition. For example, 23% of cards are new. Note that sometimes this would not make sense. For example, for the column «cards», the value will always be 100% (unless the deck is empty). For the column notes, the number would not really make any sense (formally, you'd get the percent of cards which is the first of its siblings in this deck). 63 | 64 | By default, the percent is assumed to be false if absent. 65 | 66 | ### Absolute 67 | Whether you want an absolute number in your column. That is, a number which is not a percentage, but an exact number. 68 | 69 | By default, this value is false if Percent is set to true, otherwise its default value is true. 70 | 71 | ### Subdecks 72 | When you consider a deck which has subdecks, a true value considers cards in its subdecks; a false value ignores cards in its child subdecks. 73 | 74 | ## Coloring decks 75 | The author of this add-on wants to know when a deck is empty. This is very important to him, because he wants to add new cards in them as soon as possible. Thus, this add-on changes the color of the names of empty decks, and of the names of decks with an empty descendant. 76 | 77 | The author also wants to know which deck has marked cards. Thus, the background of the deck's name having marked cards changes color. 78 | 79 | Both of these configurations can be changed as explained in this section. In particular, you can turn one or both of these options off by setting "color empty" and "color marked" to false. 80 | 81 | ### Choice of color 82 | #### Color empty 83 | The color of the names of decks without new cards 84 | 85 | #### Color empty descendant 86 | The color of the names of decks with a descendant without new cards 87 | 88 | #### Default color 89 | The color of a deck which every descendant has new cards. 90 | 91 | #### Default column color 92 | The color of the content of a deck, if no other color is specified. 93 | 94 | #### ended marked background color 95 | The color of the decks which have an ended deck with marked cards. The notion of ended deck will be explained in the next section of this documentation. 96 | 97 | #### Marked background color 98 | The color of decks who have marked cards but none of its descendants are both ended and have marked cards. 99 | 100 | ### Deck modifier 101 | A deck modifier is a symbol (or a word, etc.) whose presence in a deck name changes the meaning of the deck. When the meaning is changed, the coloration is also changed. It's not clear to the author of this add-on whether anyone apart from himself will need those, but if you want to use them, here is the explanation. 102 | 103 | The first three symbols currently have the same effect, but one day this effect may change, according to what the author wants to do. 104 | 105 | #### End symbol 106 | By default, this symbol is ";". It means that the deck is definitively done, and no new card may ever be added to it. When a deck has this symbol, neither itself nor its descendants will ever be colored. 107 | 108 | #### Given up symbol 109 | By default, this symbol is "/". To the author, it means that no new card will be added because this deck is either too hard, or not interesting enough. 110 | 111 | #### Pause symbol" 112 | By default, this symbol is "=". To the author, it means that more new cards will be added later, but right now it does not want Anki to change the color of the deck's name. In a future version, there may be an option to change the color of these decks. 113 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from aqt import mw 4 | 5 | userOption = None 6 | 7 | 8 | def getUserOption(key=None, default=None): 9 | global userOption 10 | if userOption is None: 11 | userOption = mw.addonManager.getConfig(__name__) 12 | if key is None: 13 | return userOption 14 | if key in userOption: 15 | return userOption[key] 16 | else: 17 | userOption[key] = default 18 | writeConfig() 19 | return default 20 | 21 | 22 | def writeConfig(): 23 | mw.addonManager.writeConfig(__name__, userOption) 24 | 25 | 26 | def update(_): 27 | global userOption, fromName 28 | userOption = None 29 | fromName = None 30 | 31 | 32 | mw.addonManager.setConfigUpdatedAction(__name__, update) 33 | 34 | fromName = None 35 | 36 | 37 | def getFromName(name): 38 | global fromName 39 | if fromName is None: 40 | fromName = dict() 41 | for dic in getUserOption("columns"): 42 | fromName[dic["name"]] = dic 43 | return fromName.get(name) 44 | -------------------------------------------------------------------------------- /config.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "title": "Enhance main window", 5 | "properties": { 6 | "hide values of parent decks when subdecks are shown": { 7 | "type": "boolean", 8 | "default": false 9 | }, 10 | "hide values of parent decks": { 11 | "type": "boolean", 12 | "default": false 13 | }, 14 | "default column color": { 15 | "type": "string", 16 | "default": "grey" 17 | }, 18 | "option": { 19 | "type": "boolean", 20 | "default": true 21 | }, 22 | "cap value": { 23 | "type": ["integer", "null"], 24 | "default": null 25 | }, 26 | "color empty": { 27 | "type": "string", 28 | "default": "red" 29 | }, 30 | "color empty descendant": { 31 | "type": "string", 32 | "default": "green" 33 | }, 34 | "marked background color": { 35 | "type": "string", 36 | "default": "powderblue" 37 | }, 38 | "ended marked background color": { 39 | "type": "string", 40 | "default": "yellow" 41 | }, 42 | "end symbol": { 43 | "type": "string", 44 | "default": ";" 45 | }, 46 | "book symbol": { 47 | "type": "string", 48 | "default": "{" 49 | }, 50 | "given up symbol": { 51 | "type": "string", 52 | "default": "/" 53 | }, 54 | "pause symbol": { 55 | "type": "string", 56 | "default": "=" 57 | }, 58 | "do color marked": { 59 | "type": "boolean", 60 | "default": true 61 | }, 62 | "do color empty": { 63 | "type": "boolean", 64 | "default": true 65 | }, 66 | "color zero": { 67 | "type": "boolean", 68 | "default": false 69 | }, 70 | "columns": { 71 | "type": "array", 72 | "items": { 73 | "type": "object", 74 | "properties": { 75 | "names": { 76 | "type": "array", 77 | "items": { 78 | "type": "string", 79 | "enum": [ 80 | "learning card", 81 | "learning later", 82 | "learning now", 83 | "learning today", 84 | "learning all", 85 | "review due", 86 | "due tomorrow", 87 | "review today", 88 | "review", 89 | "unseen", 90 | "unseen later", 91 | "review later", 92 | "reviewed today", 93 | "reviewed today/repeated today", 94 | "repeated today", 95 | "repeated", 96 | "new", 97 | "unseen new", 98 | "buried", 99 | "buried/suspended", 100 | "suspended", 101 | "cards", 102 | "notes/cards", 103 | "notes", 104 | "today", 105 | "undue", 106 | "mature/young", 107 | "mature", 108 | "young", 109 | "marked", 110 | "leech", 111 | "new today", 112 | "bar", 113 | "flags", 114 | "all flags", 115 | "review later", 116 | "repetition seen today", 117 | "repetition today", 118 | "cards seen today" 119 | ] 120 | } 121 | }, 122 | "description": { 123 | "type": "string", 124 | "description": "A description of this column. Not used by the add-on, here to help you understand the default." 125 | }, 126 | "name": { 127 | "type": "string", 128 | "description": "The internal name of the column. Used to know what to display", 129 | "enum": [ 130 | "learning card", 131 | "learning later", 132 | "learning now", 133 | "learning today", 134 | "learning all", 135 | "review due", 136 | "due tomorrow", 137 | "review today", 138 | "review", 139 | "unseen", 140 | "unseen later", 141 | "review later", 142 | "reviewed today", 143 | "reviewed today/repeated today", 144 | "repeated today", 145 | "repeated", 146 | "new", 147 | "unseen new", 148 | "buried", 149 | "buried/suspended", 150 | "suspended", 151 | "cards", 152 | "notes/cards", 153 | "notes", 154 | "today", 155 | "undue", 156 | "mature/young", 157 | "mature", 158 | "young", 159 | "marked", 160 | "leech", 161 | "new today", 162 | "bar", 163 | "flags", 164 | "flag 1", 165 | "flag 2", 166 | "flag 3", 167 | "flag 4", 168 | "all flags", 169 | "review later", 170 | "repetition seen today", 171 | "repetition today", 172 | "cards seen today" 173 | ] 174 | }, 175 | "color": { 176 | "type": ["string", "null"], 177 | "description": "Color of number shown in this column" 178 | }, 179 | "present": { 180 | "type": "boolean", 181 | "description": "Whether to show this column. Allow to hide the column without deleting it from the configuration." 182 | }, 183 | "absolute": { 184 | "type": "boolean", 185 | "description": "Whteher to give an absolute number." 186 | }, 187 | "percent": { 188 | "type": "boolean", 189 | "description": "Whether to give a relative number." 190 | }, 191 | "subdeck": { 192 | "type": "boolean", 193 | "description": "Do you count elements in subdecks" 194 | }, 195 | "header": { 196 | "type": ["string", "null"], 197 | "description": "The header of the column. If you leave «null» then the default header will be used. This description will be translated as much as it is possible to do it automatically. However, you can also choose to write your own description. You can use HTML in this description. You should use `
` when you want a newline.", 198 | "default": "" 199 | }, 200 | "overlay": { 201 | "type": ["string", "null"], 202 | "description": "The text shown when your mouse is over a number. It will describe what this number represents. You can set this key to false if you want no description to be present. And leave this value to null if you want to use the default value.", 203 | "default": "" 204 | } 205 | } 206 | } 207 | } 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /consts.py: -------------------------------------------------------------------------------- 1 | QUEUE_SCHED_BURIED = -3 2 | QUEUE_USER_BURIED = -2 3 | QUEUE_SUSPENDED = -1 4 | QUEUE_NEW_CRAM = 0 5 | QUEUE_LRN = 1 6 | QUEUE_REV = 2 7 | QUEUE_DAY_LRN = 3 8 | QUEUE_PREVIEW = 4 9 | -------------------------------------------------------------------------------- /counts.md: -------------------------------------------------------------------------------- 1 | # Counts 2 | Here is the list of everything counted in the add-on. Not everything 3 | can be displayed in a column. This document is mostly for people 4 | working on the code. 5 | 6 | ## Values already computed by basic Anki 7 | ### review today 8 | The number of reviewed cards to see today. 9 | 10 | ### New today 11 | The number of new cards to learn today. 12 | 13 | ### Repetition of today learning 14 | Number of reviews you'll see of cards in learning today. 15 | 16 | ## Numbers directly computed in the database 17 | ### learning now from today 18 | Number of cards in learning to see today which was planified today. 19 | 20 | ### flag i 21 | Cards flagged with flag i. 22 | 23 | ### learning today from past 24 | Cards in learning to see today and which have waited at least a day. 25 | 26 | ### learning later today 27 | Cards in learning which are due today but not now. 28 | 29 | They were last seen today. There are no cards from past days, due 30 | today but not anymore. 31 | 32 | ### learning future 33 | Cards in learning such that this review will not occur today (no way 34 | of knowing whether it's from today or from a past day) 35 | 36 | ### learning today repetition from today 37 | Number of repetitions you'll see today of cards currently in learning 38 | such that the last repetition was today. 39 | 40 | Similar to Repetition of today 41 | learning, restricting cards to the one seen today. 42 | 43 | ### learning today repetition from past 44 | Number of repetitions you'll see today of cards currently in learning 45 | such that last repetition was NOT today. 46 | 47 | Similar to last case, apart 48 | from the negation 49 | 50 | ### learning repetition from today 51 | Number of repetitions you'll see ANY day of cards currently in learning 52 | such that the last repetition was today. 53 | 54 | Similar to "learning today 55 | repetition from today" case, apart from that we count repetition not to 56 | see today. 57 | 58 | ### learning repetition from past 59 | Number of repetitions you'll see ANY day of cards currently in learning 60 | such that the last repetition was NOT today. 61 | 62 | Similar to "learning today 63 | repetition from past" case, apart from that we count repetitions not to 64 | see today. Similar to "learning repetition from today" apart from the negation. 65 | 66 | ### review due 67 | Number of cards which have already been seen and are due today (even 68 | if it's greater than the maximum number of cards the configuration allows 69 | to see for this deck). 70 | 71 | ### unseen 72 | Number of cards which have never graduated and are not in learning. 73 | 74 | ### buried 75 | Number of buried cards 76 | 77 | ### suspended 78 | Number of suspended cards 79 | 80 | ### cards 81 | Number of cards 82 | 83 | ### notes 84 | Number of notes 85 | 86 | ### undue 87 | Cards which have already been seen at least once, are not in learning, 88 | and are not due today. 89 | 90 | ### mature 91 | Any card already seen with an interval of at least 21 days 92 | 93 | ### young 94 | Any card already seen with an interval of at least one day and at most 20 days 95 | 96 | ## Sum of previous values 97 | 98 | ### learning now 99 | Number of cards in learning ready to be seen (from today+from yesterday). 100 | 101 | ### learning later 102 | Number of cards in learning not ready to be seen (to see later today, 103 | or in the future). 104 | 105 | ### learning card 106 | Number of cards in learning (now+later) 107 | 108 | ### learning today repetition 109 | Number of repetition to cards in learning today (sum of repetition 110 | from card from a past day, and from today). 111 | 112 | Isn't it equal to "Repetition of today learning"???TODO 113 | 114 | ### learning repetition 115 | Number of repetition of cards in learning, any days (sum of 116 | repetitions from today and from past days) 117 | 118 | ### learning future repetition 119 | Number of repetition of cards in learning, but not today. (Number of 120 | repetitions minus repetition to do today) 121 | 122 | ### review later 123 | Cards to review, which are due, but won't be seen today because of 124 | deck's configured limit. (review due - review today) 125 | 126 | ### reviewed today 127 | Cards whose last successful review was today. (A card deleted after 128 | review is not counted anymore. A card reviewed and moved is counted in 129 | its new deck. A card reviewed many times is counted once. Cards in 130 | learning are not counted. TODO: find how to easily find how to count 131 | cards in learning whose last review is today) 132 | 133 | ### repeated today 134 | Number of times you saw today a question from this deck. (A card 135 | deleted after review is not counted anymore. A card reviewed and moved 136 | is counted in its new deck.) 137 | 138 | ### repeated today 139 | Number of times you saw a question from this deck anytime in the 140 | past. (A card deleted after review is not counted anymore. A card 141 | reviewed and moved is counted in its new deck.) 142 | 143 | ### unseen later 144 | Cards never seen, and won't be seen today because of deck's 145 | configured limit. (unseen - new today) 146 | 147 | ### repetition seen today 148 | Number of repetitions of cards to see today which are not new 149 | 150 | ### repetition today 151 | Number of repetitions of cards to see today 152 | 153 | ### cards seen today 154 | Number of cards to see today which are not new 155 | 156 | ### today 157 | Number of cards to see today 158 | 159 | Similar to Repetition of today learning, but each card is counted 160 | once, even if it'll be seen multiple times. 161 | 162 | 163 | # Sets 164 | When we consider note, we must use sets instead of numbers. Because a 165 | note may be in multiple subdecks, and we don't want to count it 166 | multiple times. 167 | 168 | The size of the sets are then counted and added in the previous 169 | dictionnary. 170 | 171 | ### notes 172 | The set of nids from this deck 173 | 174 | ### marked 175 | The set of nids of marked notes in this deck 176 | 177 | # Texts 178 | Here, we have columns content which is more than just text 179 | 180 | ## Time 181 | ### learning now 182 | Number of minute/seconds before a card in learning can be seen (only 183 | if a value is not already given) 184 | 185 | ## Pair of values 186 | Mature/young 187 | Notes/cards 188 | Buried/suspended 189 | Reviewed/repeated today 190 | 191 | ## flags 192 | flags 1 to 4. 193 | ### all flags 194 | (including flag 0, i.e. no flag). 195 | 196 | ## Now and later 197 | 198 | ### Review 199 | review today (review later) 200 | 201 | ### unseen new 202 | new today (unseen later) 203 | 204 | ### Learning today 205 | learning now (learning later today) 206 | -------------------------------------------------------------------------------- /debug.py: -------------------------------------------------------------------------------- 1 | import re 2 | from inspect import stack 3 | 4 | # whether debug may be turned on eventually. Less efficient 5 | mayDebug = False 6 | 7 | # Whether right debuging is on 8 | shouldDebug = False 9 | 10 | 11 | def startDebug(): 12 | global shouldDebug 13 | shouldDebug = True 14 | print("Debug started") 15 | 16 | 17 | def endDebug(): 18 | global shouldDebug 19 | shouldDebug = False 20 | print("Debug ended") 21 | 22 | 23 | indentation = 0 24 | 25 | 26 | def debug(text, indentToAdd=0, force=False, level=1): 27 | if not shouldDebug and not force: 28 | return 29 | global indentation 30 | glob = stack()[level].frame.f_globals 31 | loc = stack()[level].frame.f_locals 32 | text = eval(f"""f"{text}" """, glob, loc) 33 | indentToPrint = indentation 34 | t = " "*indentToPrint 35 | if indentToAdd > 0: 36 | t += "{<" 37 | space = " " 38 | newline = "\n" 39 | t += re.sub(newline, newline+space, text) 40 | print (t) 41 | indentation += indentToAdd 42 | if indentToAdd < 0: 43 | indentToPrint += indentToAdd 44 | print((" "*indentToPrint)+">}") 45 | 46 | 47 | nbInsideThis = 0 48 | 49 | 50 | def debugInsideThisMethod(fun): 51 | if not mayDebug: 52 | return fun 53 | 54 | def aux_debugInsideThisMethod(*args, **kwargs): 55 | global nbInsideThis 56 | startDebug() 57 | nbInsideThis += 1 58 | ret = fun(*args, **kwargs) 59 | nbInsideThis -= 1 60 | if nbInsideThis == 0: 61 | endDebug() 62 | return ret 63 | return aux_debugInsideThisMethod 64 | 65 | 66 | def debugOnlyThisMethod(fun): 67 | return debugFun(fun, (lambda text, indentToAdd=0: debug(text, indentToAdd, force=True, level=2))) 68 | 69 | 70 | def assertEqual(left, right): 71 | if left == right: 72 | return True 73 | print(f"""\n\nReceived\n\"\"\"{left}\"\"\"\nwhich is distinct from expected\n\"\"\"{right}\"\"\"\n""") 74 | if hasattr(left, "firstDifference"): 75 | if hasattr(right, "firstDifference"): 76 | pair = left.firstDifference(right) 77 | if isinstance(pair, tuple): 78 | left_dif, right_dif = pair 79 | print(f"""\n\nThe first difference is\n\"\"\"{left_dif}\"\"\"\nand\n\"\"\"{right_dif}\"\"\"\n""") 80 | elif isinstance(pair, None): 81 | print("Strangely, firstDifference find no difference") 82 | else: 83 | assert False 84 | else: 85 | print("Only the first is a Gen") 86 | elif hasattr(right, "firstDifference"): 87 | print("Only the second is a Gen") 88 | return False 89 | 90 | # def assertEqualString(left, right): 91 | # glob = stack()[1].frame.f_globals 92 | # loc = stack()[1].frame.f_locals 93 | # # try: 94 | # leftEval = eval(left, glob, loc) 95 | # # except NameError as n: 96 | # # print(f"""glob is {glob}""") 97 | # # raise 98 | # rightEval = eval(right,glob,loc) 99 | # if leftEval == rightEval: 100 | # return True 101 | # print(f"""\n\n{left} evaluates as \n"{leftEval}".\n"{rightEval}"\n is the value of {right}, they are distinct.""") 102 | # return False 103 | 104 | 105 | def assertType(element, types): 106 | if not isinstance(types, list): 107 | types = [types] 108 | for typ in types: 109 | if isinstance(element, typ): 110 | return True 111 | print(f""" "{element}"'s type is {type(element)}, which is not a subtype of {types}""") 112 | return False 113 | 114 | 115 | def debugFun(fun, debug=debug): 116 | if not mayDebug: 117 | return fun 118 | 119 | def aux_debugFun(*args, **kwargs): 120 | nonlocal debug 121 | t = f"{fun.__qualname__}(" 122 | first = False 123 | 124 | def comma(text): 125 | nonlocal first, t 126 | if not first: 127 | first = True 128 | else: 129 | t += ", " 130 | t += text 131 | for arg in args: 132 | comma(f"{arg}") 133 | for kw in kwargs: 134 | comma(f"{kw}={kwargs[kw]}") 135 | t += ")" 136 | debug("{t}", 1) 137 | ret = fun(*args, **kwargs) 138 | debug("returns {ret}", -1) 139 | return ret 140 | aux_debugFun.__name__ = f"debug_{fun.__name__}" 141 | aux_debugFun.__qualname__ = f"debug_{fun.__qualname__}" 142 | return aux_debugFun 143 | 144 | 145 | def debugInit(fun, debug=debug): 146 | if not mayDebug: 147 | return fun 148 | 149 | def aux_debugInit(self, *args, **kwargs): 150 | t = f"{fun.__name__}(" 151 | needSeparator = False 152 | 153 | def comma(text): 154 | nonlocal needSeparator, t 155 | if not needSeparator: 156 | needSeparator = True 157 | else: 158 | t += ", " 159 | t += text 160 | isSelf = True 161 | for arg in args: 162 | if isSelf: 163 | isSelf = False 164 | continue 165 | comma(f"{arg}") 166 | for kw in kwargs: 167 | comma(f"{kw}={kwargs[kw]}") 168 | t += ")" 169 | debug("{t}", 1) 170 | fun(self, *args, **kwargs) 171 | debug("returns {self}", -1) 172 | aux_debugInit.__name__ = f"debug_{fun.__name__}" 173 | aux_debugInit.__qualname__ = f"debug_{fun.__qualname__}" 174 | return aux_debugInit 175 | 176 | 177 | def debugOnlyThisInit(fun): 178 | return debugInit(fun, (lambda text, indentToAdd=0: debug(text, indentToAdd, force=True, level=2))) 179 | 180 | 181 | class ExceptionInverse(Exception): 182 | def __init__(self, text): 183 | self.text = "\n".join(reversed((str(text)+"\n").split("\n"))) 184 | 185 | def __str__(self): 186 | return f"Exception: {self.text}" 187 | -------------------------------------------------------------------------------- /deckbrowser.js: -------------------------------------------------------------------------------- 1 | /* Copyright: Ankitects Pty Ltd and contributors 2 | * License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */ 3 | 4 | 5 | function init() { 6 | 7 | 8 | $("tr.deck").draggable({ 9 | scroll: false, 10 | 11 | // can't use "helper: 'clone'" because of a bug in jQuery 1.5 12 | helper: function (event) { 13 | return $(this).clone(false); 14 | }, 15 | delay: 200, 16 | opacity: 0.7 17 | }); 18 | $("th.count").draggable({ 19 | scroll: false, 20 | 21 | // can't use "helper: 'clone'" because of a bug in jQuery 1.5 22 | helper: function (event) { 23 | return $(this).clone(false); 24 | }, 25 | delay: 200, 26 | opacity: 0.7 27 | }); 28 | $("tr.deck").droppable({ 29 | drop: handleDropEvent, 30 | hoverClass: 'drag-hover' 31 | }); 32 | $("th.count").droppable({ 33 | drop: columnDropEvent, 34 | hoverClass: 'drag-hover' 35 | }); 36 | $("tr.top-level-drag-row").droppable({ 37 | drop: handleDropEvent, 38 | hoverClass: 'drag-hover' 39 | }); 40 | } 41 | $(init); 42 | 43 | function handleDropEvent(event, ui) { 44 | var draggedDeckId = ui.draggable.attr('id'); 45 | var ontoDeckId = $(this).attr('id') || ''; 46 | 47 | pycmd("drag:" + draggedDeckId + "," + ontoDeckId); 48 | } 49 | 50 | function columnDropEvent(event, ui) { 51 | var draggedDeckId = ui.draggable.attr('colpos'); 52 | var ontoDeckId = $(this).attr('colpos') || ''; 53 | pycmd("dragColumn:" + draggedDeckId + "," + ontoDeckId); 54 | } 55 | -------------------------------------------------------------------------------- /defaultcss.css: -------------------------------------------------------------------------------- 1 | /* Tooltip container */ 2 | a:hover{ 3 | cursor: pointer; 4 | } 5 | 6 | /* Tooltip text */ 7 | .tooltip .tooltiptext { 8 | visibility: hidden; 9 | background-color: black; 10 | color: #fff; 11 | text-align: center; 12 | padding: 5px 0; 13 | border-radius: 6px; 14 | 15 | /* Position the tooltip text - see examples below! */ 16 | position: absolute; 17 | z-index: 1; 18 | } 19 | 20 | /* Show the tooltip text when you mouse over the tooltip container */ 21 | .tooltip:hover .tooltiptext { 22 | visibility: visible; 23 | } 24 | 25 | /* padding-left for header columns except deck-column */ 26 | th.count { 27 | padding-left:15px; 28 | cursor: pointer; 29 | } 30 | 31 | .openDeck .number_cell { 32 | visibility: hidden; 33 | } 34 | -------------------------------------------------------------------------------- /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arthur-Milchior/anki-enhance-main-window/98cc6815ef3674e19909180a4d4bddf23844b7a3/example.png -------------------------------------------------------------------------------- /htmlAndCss.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from anki.lang import _ 4 | 5 | from .config import getUserOption 6 | 7 | __location__ = os.path.realpath( 8 | os.path.join(os.getcwd(), os.path.dirname(__file__))) 9 | js_file = os.path.join(__location__, "deckbrowser.js") 10 | css_file = os.path.join(__location__, "defaultcss.css") 11 | 12 | with open(js_file, "r") as f: 13 | js = f.read() 14 | with open(css_file, "r") as f: 15 | css = f.read() 16 | 17 | 18 | ###################### 19 | #header related html # 20 | ###################### 21 | start_header = """ 22 | """ 23 | 24 | deck_header = f""" 25 | 26 | {_("Deck")} 27 | """ 28 | 29 | 30 | def column_header(heading, colpos): 31 | return f""" 32 | 33 | 34 | {_(heading)} 35 | 36 | """ 37 | 38 | 39 | option_header = """ 40 | """ 41 | 42 | option_name_header = """ 43 | """ 44 | 45 | end_header = """ 46 | """ 47 | 48 | 49 | ############## 50 | #deck's html # 51 | ############## 52 | def start_line(klass, did): 53 | return f""" 54 | """ 55 | 56 | 57 | def collapse_children_html(did, name, prefix): 58 | return f""" 59 | 60 | {prefix} 61 | """ 62 | 63 | 64 | collapse_no_child = """ 65 | """ 66 | 67 | 68 | def deck_name(depth, collapse, extraclass, did, cssStyle, name): 69 | return f""" 70 | 71 | {" "*6*depth}{collapse} 72 | 73 | 74 | {name} 75 | 76 | 77 | 78 | """ 79 | 80 | 81 | def number_cell(colour, number, description): 82 | if description is None or description is False: 83 | description = "" 84 | t = f""" 85 | """ 86 | else: 87 | description = f""" 88 | 89 | {description} 90 | """ 91 | t = f""" 92 | """ 93 | # if number: 94 | t += f""" 95 | 96 | {number} 97 | """ 98 | if description: 99 | t += f""" 100 | {description}""" 101 | t += """ 102 | """ 103 | return t 104 | 105 | 106 | def gear(did): 107 | return f""" 108 | 109 | 110 | 111 | 112 | """ 113 | 114 | 115 | def deck_option_name(option): 116 | return f""" 117 | 118 | {option} 119 | """ 120 | 121 | 122 | end_line = """ 123 | """ 124 | 125 | 126 | def bar(name, width, left, color, overlay): 127 | return f""" 128 |
129 | 130 | 131 | {overlay} 132 | 133 |
""" 134 | 135 | 136 | def progress(content): 137 | return f""" 138 |
{content} 139 |
""" 140 | -------------------------------------------------------------------------------- /node.py: -------------------------------------------------------------------------------- 1 | import copy 2 | import sys 3 | import time 4 | 5 | from anki.utils import ids2str, intTime 6 | from aqt import mw 7 | from aqt.qt import * 8 | from aqt.utils import downArrow 9 | 10 | from . import tree 11 | from .config import getFromName, getUserOption, writeConfig 12 | from .debug import debug 13 | from .htmlAndCss import (bar, collapse_children_html, collapse_no_child, 14 | column_header, css, deck_header, deck_name, 15 | deck_option_name, end_header, end_line, gear, js, 16 | number_cell, option_header, option_name_header, 17 | progress, start_header, start_line) 18 | from .printing import conditionString, nowLater 19 | from .strings import getColor, getHeader, getOverlay 20 | 21 | debugWrongLine = debug 22 | 23 | 24 | # Dict from deck id to deck node 25 | idToNode = dict() 26 | idToOldNode = dict() 27 | 28 | 29 | def idFromOldNode(node): 30 | # Look at aqt/deckbrowser.py for a description of node 31 | try: 32 | (_, did, _, _, _, _) = node 33 | return did 34 | except: 35 | return node.deck_id 36 | 37 | 38 | # The list of column in configuration which does not exists, and such that the user was already warned about it. 39 | warned = set() 40 | 41 | 42 | class DeckNode: 43 | """A node in the new more advanced deck tree. 44 | 45 | name -- the name of the deck 46 | did -- the id of the deck 47 | dueRevCards -- number of review to see today 48 | dueLrnReps -- numbers of cards in learning 49 | newCards -- number of new cards to see today 50 | children -- the set of children, as decknode 51 | deck -- the deck objects 52 | 53 | Information to potentially display 54 | count -- associate to [absolute/percent][deck/subdeck][isThisAString][value] the number/percent of cards satisfying value in the deck (and its subdeck) 55 | set -- associate to [deck/subdeck][value] the set of nids satisfying "value" in the deck (and its subdeck) 56 | markedNotesRec -- the set of marked notes in the deck and its subdkc 57 | endedMarkedDescendant -- whether the deck has a descendant ended with marked cards 58 | timeDue[deck/subdeck] -- the number of seconds before the first card in learning will be seen 59 | isEmpty -- whether deck and subdecks has no unseen cards 60 | 61 | Conf parameters 62 | isFiltered -- whether this is a filtered deck 63 | confName -- the name of the configuration of this deck ('Filtered' if filtered) 64 | 65 | content of the deck's name: 66 | containsEndSymbol -- whether the deck's name contains the end symbol 67 | containsPauseSymbol 68 | containsBookSymbol 69 | containsGivenUpSymbol 70 | 71 | content of the deck's parent: 72 | endedParent -- whether an ancestor's deck name contains the end symbol 73 | givenUpParent 74 | pauseParent 75 | 76 | content of the deck: 77 | ended -- whether the deck is ended according to a symbol 78 | givenUp 79 | """ 80 | 81 | def __init__(self, mw, oldNode, endedParent=False, givenUpParent=False, pauseParent=False): 82 | # Look at aqt/deckbrowser.py for a description of oldNode 83 | "Build the new deck tree or subtree (with extra info) by traversing the old one." 84 | 85 | # Associate each of the potentially interesting parameters of this node 86 | self.param = dict() 87 | # CSS Style 88 | self.style = dict() 89 | self.mw = mw 90 | self.endedParent = endedParent 91 | self.pauseParent = pauseParent 92 | self.givenUpParent = givenUpParent 93 | try: 94 | self.name, self.did, self.dueRevCards, self.dueLrnReps, self.newCardsToday, self.oldChildren = oldNode 95 | except: 96 | self.name = oldNode.name; self.did = oldNode.deck_id; self.dueRevCards = oldNode.review_count; self.dueLrnReps = oldNode.learn_count; self.newCardsToday = oldNode.new_count; self.oldChildren = oldNode.children; 97 | self.deck = mw.col.decks.get(self.did) 98 | 99 | self.initDicts() 100 | self.setSymbolsParameters() 101 | self.setChildren() 102 | self.setDeckLevel() 103 | self.setSubdeck() 104 | 105 | self.fromSetToCount() 106 | self.setText() 107 | 108 | def setDeckLevel(self): 109 | """Compute every informations which does not need access to 110 | children """ 111 | self.setConfParameters() 112 | self.initCountFromDb() # count information of card from database 113 | self.initNid() # set of note from database 114 | self.initTagged() # set of marked/lapsed notes 115 | self.initTimeDue() 116 | self.initFromAlreadyComputed() 117 | self.initCountSum() # basic sum from database information 118 | 119 | def setSubdeck(self): 120 | self.setEndedMarkedDescendant() 121 | self.setSubdeckCount() # Sum of subdecks value 122 | self.setSubdeckSets() # Union of subdecks set 123 | self.setTimeDue() 124 | self.setEmpty() 125 | self.setPercentAndBoth() 126 | 127 | def setConfParameters(self): 128 | """ Find the configuration and its name """ 129 | if "conf" in self.deck: # a classical deck 130 | conf = mw.col.decks.confForDid(self.deck["id"]) 131 | self.isFiltered = False 132 | self.confName = conf['name'] 133 | else: 134 | self.isFiltered = True 135 | self.confName = "Filtered" 136 | 137 | def testSymbolInName(self, symbolName): 138 | """ Whether the symbol associate to symbol name in the 139 | configuration occurs in the deck's name""" 140 | symbol = getUserOption(symbolName) 141 | if symbol is None: 142 | return False 143 | return symbol in self.name 144 | 145 | def setSymbolsParameters(self): 146 | """ Read the deck name and gather information from it""" 147 | self.containsEndSymbol = self.testSymbolInName("end symbol") 148 | self.containsPauseSymbol = self.testSymbolInName("pause symbol") 149 | self.containsBookSymbol = self.testSymbolInName("book symbol") 150 | self.containsGivenUpSymbol = self.testSymbolInName("given up symbol") 151 | self.ended = self.endedParent or self.containsEndSymbol 152 | self.givenUp = self.givenUpParent or self.containsGivenUpSymbol 153 | self.pause = self.pauseParent or self.containsPauseSymbol 154 | 155 | def initDicts(self): 156 | """ Ensure that each dictionarry is created""" 157 | self.count = dict() 158 | for absoluteOrPercent in ["absolute", "percent", "both"]: 159 | self.count[absoluteOrPercent] = dict() 160 | for kind in ["deck", "subdeck"]: 161 | self.count[absoluteOrPercent][kind] = dict() 162 | for isString in [True, False]: 163 | self.count[absoluteOrPercent][kind][isString] = dict() 164 | self.noteSet = dict() 165 | for kind in ["deck", "subdeck"]: 166 | self.noteSet[kind] = dict() 167 | 168 | def initCountFromDb(self): 169 | for name in tree.values: 170 | self.addCount("absolute", "deck", False, name, 171 | tree.values[name].get(self.did, 0)) 172 | 173 | def initFromAlreadyComputed(self): 174 | """Put in dict values already computed by anki""" 175 | for subdeckNumber, name in [(self.dueRevCards, "review today"), (self.newCardsToday, "new today"), (self.dueLrnReps, "repetition of today learning")]: 176 | deckNumber = subdeckNumber 177 | for child in self.children: 178 | deckNumber -= child.count["absolute"]["subdeck"][False][name] 179 | self.addCount("absolute", "deck", False, name, deckNumber) 180 | self.addCount("absolute", "subdeck", False, name, subdeckNumber) 181 | 182 | def absoluteDeckSum(self, newName, sum1, sum2, negate=False): 183 | sum1 = self.count["absolute"]["deck"][False][sum1] 184 | sum2 = self.count["absolute"]["deck"][False][sum2] 185 | if negate: 186 | sum2 = -sum2 187 | self.addCount("absolute", "deck", False, newName, (sum1+sum2)) 188 | 189 | def initCountSum(self): 190 | self.absoluteDeckSum( 191 | "learning now", "learning now from today", "learning today from past") 192 | self.absoluteDeckSum( 193 | "learning later", "learning later today", "learning future") 194 | self.absoluteDeckSum("learning card", "learning now", "learning later") 195 | self.absoluteDeckSum( 196 | "learning today", "learning later today", "learning now") 197 | 198 | # Repetition 199 | self.absoluteDeckSum("learning today repetition", 200 | "learning today repetition from today", "learning today repetition from past") 201 | self.absoluteDeckSum( 202 | "learning repetition", "learning repetition from today", "learning repetition from past") 203 | self.absoluteDeckSum("learning future repetition", 204 | "learning repetition", "learning today repetition", negate=True) 205 | 206 | # Review 207 | self.absoluteDeckSum("review later", "review due", 208 | "review today", negate=True) 209 | self.absoluteDeckSum("unseen later", "unseen", 210 | "new today", negate=True) 211 | self.absoluteDeckSum("repetition seen today", 212 | "repetition of today learning", "review today") 213 | self.absoluteDeckSum("repetition today", 214 | "repetition seen today", "new today") 215 | self.absoluteDeckSum("cards seen today", 216 | "learning today", "review today") 217 | self.absoluteDeckSum("today", "cards seen today", "new today") 218 | 219 | def initNid(self): 220 | """ set the set of nids of this deck""" 221 | self.addSet("deck", "notes", set(mw.col.db.list( 222 | """select nid from cards where did = ?""", self.did))) 223 | 224 | def initTagged(self): 225 | """ set the set of marked cards of this deck, and someMarked""" 226 | self.addSet("deck", "marked", set(mw.col.db.list( 227 | """select id from notes where tags like '%marked%' and (not (tags like '%notMain%')) and id in """ + ids2str(self.noteSet["deck"]["notes"])))) 228 | self.addSet("deck", "leech", set(mw.col.db.list( 229 | """select id from notes where tags like '%leech%' and (not (tags like '%notMain%')) and id in """ + ids2str(self.noteSet["deck"]["notes"])))) 230 | self.someMarked = bool(self.noteSet["deck"]["marked"]) 231 | 232 | # if self.containsBookSymbol: 233 | # self.endedMarkedDescendant = self.endedMarkedDescendant and self.containsEndSymbol and self.isEmpty 234 | # if self.markedNotes and self.containsEndSymbol and self.isEmpty: 235 | # self.endedMarkedDescendant = True 236 | # self.addCount("absolute","deck","marked", len(self.markedNotes)) 237 | # self.addCount("absolute","subdeck","marked", len(self.markedNotesRec)) 238 | # self.param["someMarked"] = self.count["absolute"]["subdeck"]["marked"]>0 239 | 240 | # self.endedMarkedDescendant = False 241 | 242 | def initTimeDue(self): 243 | """find the time before the first element in learning can be seen""" 244 | self.timeDue = dict() 245 | fromTree = tree.times.get(self.did, 0) 246 | self.timeDue["deck"] = fromTree or 0 247 | debug( 248 | """For deck {self.name} with id {self.did!r}, we get from tree {fromTree} and thus {self.timeDue["deck"]}.""") 249 | 250 | def setChildren(self): 251 | """ create node from every child and save them in 252 | self.children """ 253 | self.children = list() 254 | for oldChild in self.oldChildren: 255 | childNode = make(oldChild, self.ended, self.givenUp, self.pause) 256 | self.children.append(childNode) 257 | 258 | def setEndedMarkedDescendant(self): 259 | """ check whether there is a descendant empty deck with a marked note. 260 | Set the background color appropriately""" 261 | self.endedMarkedDescendant = False 262 | if self.ended and self.someMarked: 263 | self.endedMarkedDescendant = True 264 | return 265 | for child in self.children: 266 | if child.endedMarkedDescendant: 267 | self.endedMarkedDescendant = True 268 | return 269 | if self.someMarked and getUserOption("do color marked", False): 270 | if self.endedMarkedDescendant: 271 | self.style["background-color"] = getUserOption( 272 | "ended marked background color") 273 | else: 274 | self.style["background-color"] = getUserOption( 275 | "marked background color") 276 | 277 | def setSubdeckCount(self): 278 | """Compute subdeck value, as the sum of deck, and children's subdeck value""" 279 | for name in self.count["absolute"]["deck"][False]: 280 | count = self.count["absolute"]["deck"][False][name] 281 | for child in self.children: 282 | childNb = child.count["absolute"]["subdeck"][False][name] 283 | if not isinstance(childNb, int): 284 | debugWrongLine( 285 | "For child {child.name}, the value of {name} is not an int but {childNb}") 286 | if not isinstance(childNb, int): 287 | debugWrongLine(f"childNb for «{name}» is «{childNb}»") 288 | count += childNb 289 | self.addCount("absolute", "subdeck", False, name, count) 290 | 291 | def setSubdeckSets(self): 292 | """Compute subdeck's set as union of the deck set and children subdecks set""" 293 | for name in self.noteSet["deck"]: 294 | newSet = self.noteSet["deck"][name] 295 | for child in self.children: 296 | newSet |= child.noteSet["subdeck"][name] 297 | self.addSet("subdeck", name, newSet) 298 | 299 | def setTimeDue(self): 300 | """Compute first time due for subdeck using the timedue of this deck, 301 | and the one of subdecks""" 302 | self.timeDue["subdeck"] = self.timeDue["deck"] 303 | for child in self.children: 304 | if self.timeDue["subdeck"]: 305 | if child.timeDue["subdeck"]: 306 | self.timeDue["subdeck"] = min( 307 | self.timeDue["subdeck"], child.timeDue["subdeck"]) 308 | else: 309 | self.timeDue["subdeck"] = child.timeDue["subdeck"] 310 | 311 | def setEmpty(self): 312 | """Set value of isEmpty and hasEmptyDescendant. Set the colors appropriately.""" 313 | if not getUserOption("do color empty"): 314 | return 315 | self.isEmpty = self.count["absolute"]["subdeck"][False]["unseen"] == 0 316 | self.hasEmptyDescendant = self.isEmpty 317 | 318 | if self.isEmpty: 319 | if not self.ended and not self.givenUp and not self.pause: 320 | self.style["color"] = getUserOption("color empty", "black") 321 | return 322 | for child in self.children: 323 | if (child.hasEmptyDescendant and (not child.ended) and (not child.givenUp) and (not child.pause)): 324 | self.hasEmptyDescendant = True 325 | self.style['color'] = getUserOption( 326 | "color empty descendant", "black") 327 | return 328 | 329 | def _setPercentAndBoth(self, kind, column, base): 330 | """Set percent and both count values for this kind and column. In theory, column is a subset of base. 331 | 332 | Returns the numerator if its non null and there are no cards.""" 333 | ret = None 334 | numerator = self.count["absolute"][kind][False][column] 335 | denominator = self.count["absolute"][kind][False][base] 336 | if numerator == 0: 337 | percent = 0 338 | percentText = "0%" 339 | # base can't be empty since a subset of it is not empty, as ensured by the above test 340 | else: 341 | if denominator == 0: 342 | percent = 0 343 | percentText = f"{numerator}/{denominator} ?" 344 | ret = numerator 345 | else: 346 | percent = (100*numerator)/denominator 347 | percentText = f"{int(percent)}%" 348 | self.addCount("percent", kind, False, column, percent) 349 | self.addCount("percent", kind, True, column, percentText) 350 | both = conditionString(numerator, f"{numerator}|{percentText}") 351 | self.addCount("both", kind, True, column, both) 352 | return ret 353 | 354 | def makeBar(self, kind, names): 355 | total = 0 356 | for name in names: 357 | total += self.count['absolute'][kind][False].get(name, 0) 358 | if total == 0: # empty decks don't get progress bars 359 | return "" 360 | cumulative = 0 361 | content = "" 362 | for name in names: 363 | conf = getFromName(name) or {"name": name} 364 | color = getColor(conf) 365 | number = self.count['absolute'][kind][False].get(name, 0) 366 | overlay = f"{number}: {getOverlay(conf)}" 367 | width = number*100/total 368 | content += bar(name, width, cumulative, color, overlay) 369 | cumulative += width 370 | return progress(content) 371 | 372 | def setPercentAndBoth(self): 373 | """Set percent and both count values for each kind and column 374 | percent. Only considering cards. 375 | 376 | Print in case of division by 0 for the percent computation. 377 | """ 378 | for kind in self.count["absolute"]: 379 | for column in self.count["absolute"][kind][False]: 380 | ret = self._setPercentAndBoth(kind, column, "cards") 381 | if ret is not None: 382 | debugWrongLine(f"""{self.name}.count["absolute"]["{kind}"]["{column}"] is {ret}, while for cards its 0: """+str(self.count["absolute"][kind][True]["cards"])) 383 | 384 | def fromSetToCount(self): 385 | """Add numbers according to number of notes, for deck, subdeck, absolute, percent, both""" 386 | for kind in ["deck", "subdeck"]: 387 | for name in self.noteSet[kind]: 388 | self.addCount("absolute", kind, False, name, 389 | len(self.noteSet[kind][name])) 390 | for name in self.noteSet[kind]: 391 | self._setPercentAndBoth(kind, name, "notes") 392 | 393 | def setLearningAll(self): 394 | """Set text for learning all""" 395 | for absoluteOrPercent in self.count: 396 | for kind in ["deck", "subdeck"]: 397 | future = self.count[absoluteOrPercent][kind][True]["learning future"] 398 | if future: 399 | later = nowLater( 400 | self.count[absoluteOrPercent][kind][True]["learning later today"], future) 401 | else: 402 | later = conditionString( 403 | self.count[absoluteOrPercent][kind][True]["learning later today"], parenthesis=True) 404 | string = nowLater( 405 | self.count[absoluteOrPercent][kind][True]["learning now"], later) 406 | self.addCount(absoluteOrPercent, kind, 407 | True, "learning all", string) 408 | 409 | def setTextTime(self): 410 | """set text for the time remaining before next card""" 411 | for kind in ["deck", "subdeck"]: 412 | learningNow = self.count["absolute"][kind][False]["learning now"] 413 | debug( 414 | """{self.name}[{kind}]=={learningNow}. Time due is {self.timeDue[kind]}.""") 415 | for absoluteOrPercent in self.count: 416 | if ((not learningNow)) and (self.timeDue[kind] != 0): 417 | remainingSeconds = self.timeDue[kind] - intTime() 418 | if remainingSeconds >= 60: 419 | self.addCount(absoluteOrPercent, kind, True, "learning now", "[%dm]" % ( 420 | remainingSeconds // 60)) 421 | else: 422 | self.addCount(absoluteOrPercent, kind, True, 423 | "learning now", "[%ds]" % remainingSeconds) 424 | debug( 425 | """Thus we set it to be time {self.count[absoluteOrPercent][kind][True]["learning now"]}""") 426 | 427 | def setFlags(self): 428 | flagColor = {1: "red", 2: "orange", 3: "green", 4: "blue"} 429 | for absoluteOrPercent in self.count: 430 | for kind in ["deck", "subdeck"]: 431 | hasFlag = False 432 | for i in range(1, 5): 433 | if self.count[absoluteOrPercent][kind][False].get(f"flag {i}"): 434 | hasFlag = True 435 | break 436 | value = "/".join([f"""{self.count[absoluteOrPercent][kind][True][f"flag {i}"]}""" for i in range(1, 5)]) 437 | self.addCount(absoluteOrPercent, kind, True, 438 | "flags", conditionString(hasFlag, value)) 439 | value = self.count[absoluteOrPercent][kind][True]["flag 0"]+"/"+value 440 | self.addCount(absoluteOrPercent, kind, True, "all flags", conditionString( 441 | hasFlag or self.count[absoluteOrPercent][kind][False].get("flag 0"), value)) 442 | 443 | def setPairs(self): 444 | """Set text for columns which are pair""" 445 | for absoluteOrPercent in self.count: 446 | for kind in ["deck", "subdeck"]: 447 | for first, second in [("mature", "young"), ("notes", "cards"), ("buried", "suspended"), ("reviewed today", "repeated today")]: 448 | name = f"{first}/{second}" 449 | firstValue = self.count[absoluteOrPercent][kind][True][first] 450 | secondValue = self.count[absoluteOrPercent][kind][True][second] 451 | values = conditionString(firstValue or secondValue, f"{firstValue}/{secondValue}") 452 | self.addCount(absoluteOrPercent, kind, True, name, values) 453 | 454 | def setNowLaters(self): 455 | """ Set text for the pairs with cards to see now, and other to see later/another day""" 456 | for absoluteOrPercent in self.count: 457 | for kind in ["deck", "subdeck"]: 458 | for name, left, right in [ 459 | ("review", "review today", "review later"), 460 | ("unseen new", "new today", "unseen later"), 461 | ("learning today", "learning now", "learning later today"), 462 | ]: 463 | value = nowLater(self.count[absoluteOrPercent][kind][True] 464 | [left], self.count[absoluteOrPercent][kind][True][right]) 465 | self.addCount(absoluteOrPercent, kind, True, name, value) 466 | 467 | def setText(self): 468 | self.setTextTime() 469 | self.setLearningAll() 470 | self.setFlags() 471 | self.setPairs() 472 | self.setNowLaters() 473 | 474 | # End of initialization 475 | ########### 476 | # Initialization tool 477 | 478 | def addCount(self, absoluteOrPercent, kind, isString, name, value): 479 | """Ensure that self.count[absoluteOrPercent][kind][name] is defined and equals value""" 480 | debug( 481 | "Adding {self.did}, {absoluteOrPercent}, {kind}, {isString}, {name}, {value}") 482 | self.count[absoluteOrPercent][kind][isString][name] = value 483 | if isString is False: 484 | if value: 485 | self.count[absoluteOrPercent][kind][True][name] = "{:,}".format( 486 | value) 487 | else: 488 | self.count[absoluteOrPercent][kind][True][name] = "" 489 | 490 | def addSet(self, kind, name, value): 491 | """Ensure that self.noteSet[kind][name] is defined and equals value""" 492 | self.noteSet[kind][name] = value 493 | 494 | ######################## 495 | # Printing 496 | def emptyRow(self, cnt): 497 | if self.did == 1 and cnt > 1 and not self.children: 498 | # if the default deck is empty, hide it 499 | if not self.count["absolute"]["subdeck"][False]["cards"]: 500 | return True 501 | # parent toggled for collapsing 502 | for parent in mw.col.decks.parents(self.did): 503 | if parent['collapsed']: 504 | return True 505 | 506 | def getOpenTr(self, collapsed, haveSubdeck): 507 | showSubdeck = haveSubdeck and not collapsed 508 | klasses = ["deck"] 509 | if self.did == mw.col.get_config('curDeck'): 510 | klasses.append('current') 511 | if ((getUserOption("hide values of parent decks") and haveSubdeck) or 512 | (getUserOption("hide values of parent decks when subdecks are shown") and showSubdeck)) : 513 | klasses.append("openDeck") 514 | return start_line(" ".join(klasses), self.did) 515 | 516 | def getCss(self): 517 | cssStyle = "" 518 | for name, value in self.style.items(): 519 | cssStyle += "%s:%s;" % (name, value) 520 | return cssStyle 521 | 522 | def getCollapse(self): 523 | # We reload the deck. The collapsed state may have changed. 524 | self.deck = mw.col.decks.get(self.did) 525 | prefix = "+" if self.deck['collapsed'] else "-" 526 | # deck link 527 | if self.children: 528 | return collapse_children_html(self.did, self.deck["name"], prefix) 529 | else: 530 | return collapse_no_child 531 | 532 | def getExtraClass(self): 533 | if self.deck['dyn']: 534 | return " filtered" 535 | else: 536 | return "" 537 | 538 | def getName(self, depth): 539 | return deck_name(depth, self.getCollapse(), self.getExtraClass(), self.did, self.getCss(), self.name) 540 | 541 | def getNumberColumns(self): 542 | buf = "" 543 | for conf in getUserOption("columns"): 544 | if conf.get("present", True): 545 | name = conf["name"] 546 | if name == "new": 547 | # It used to be called "new". Introduced back for retrocomputability. 548 | name = "new today" 549 | conf["name"] = "new today" 550 | writeConfig() 551 | if conf.get("percent", False): 552 | if conf.get("absolute", False): 553 | number = "both" 554 | else: 555 | number = "percent" 556 | else: 557 | number = "absolute" 558 | kind = "subdeck" if conf.get("subdeck", False) else "deck" 559 | if name == "bar": 560 | if not "names" in conf: 561 | print("""A configuration whose name is "bar", should have a field "names".""", file=sys.stderr) 562 | continue 563 | contents = self.makeBar(kind, conf["names"]) 564 | else: 565 | countNumberKind = self.count[number][kind][True] 566 | if name not in countNumberKind: 567 | if name not in warned: 568 | warned.add(name) 569 | debug( 570 | "The add-on enhance main window does not know any column whose name is {name}. It thus won't be displayed. Please correct your add-on's configuration.", file=sys.stderr) 571 | continue 572 | contents = countNumberKind[name] 573 | colour = getColor(conf) 574 | # In some case, we decided contents is empty. Instead of having complex value such as "0/0%" or "0(0)". Then we set it back to 0, which nicely summarize everything. 575 | if contents == "": 576 | contents = 0 577 | if contents in [0, "0", "0%", ""]: 578 | whatToDo = getUserOption("color zero") 579 | if whatToDo is False: 580 | contents = "" 581 | elif isinstance(whatToDo, str): 582 | colour = whatToDo 583 | buf += number_cell(colour, contents, getOverlay(conf)) 584 | return buf 585 | 586 | def getOptionName(self): 587 | if getUserOption("option"): # If it's not filtered 588 | return deck_option_name(self.confName) 589 | return "" 590 | 591 | def htmlRow(self, col, depth, cnt): 592 | "Generate the HTML table cells for this row of the deck tree." 593 | if self.emptyRow(cnt): 594 | return "" 595 | return ( 596 | self.getOpenTr(self.deck['collapsed'], self.children) + 597 | self.getName(depth) + 598 | self.getNumberColumns() + 599 | gear(self.did) + 600 | self.getOptionName() + 601 | end_line + 602 | col._renderDeckTree(self.children, depth+1) 603 | ) 604 | 605 | 606 | def make(oldNode, endedParent=False, givenUpParent=False, pauseParent=False): 607 | """Essentially similar to DeckNode, but return an element already computed if it exists in the base""" 608 | did = idFromOldNode(oldNode) 609 | if oldNode is not idToOldNode.get(did): 610 | node = DeckNode(mw, oldNode, endedParent, givenUpParent, pauseParent) 611 | idToNode[did] = node 612 | idToOldNode[did] = oldNode 613 | return idToNode[did] 614 | 615 | # based on Anki 2.0.36 aqt/deckbrowser.py DeckBrowser._renderDeckTree 616 | 617 | 618 | def renderDeckTree(self, nodes, depth=0): 619 | # Look at aqt/deckbrowser.py for a description of oldNode 620 | if not nodes: 621 | return "" 622 | if depth == 0: 623 | tree.computeValues() 624 | tree.computeTime() 625 | buf = f"""{start_header}{deck_header}""" 626 | for colpos, conf in enumerate(getUserOption("columns")): 627 | if conf.get("present", True): 628 | buf += column_header(getHeader(conf), colpos) 629 | buf += option_header # for deck's option 630 | if getUserOption("option"): 631 | buf += option_name_header 632 | buf += end_header 633 | 634 | # convert nodes 635 | try: 636 | nodes = [make(node) for node in nodes] 637 | except: 638 | nodes = [make(node) for node in nodes.children] 639 | 640 | buf += self._topLevelDragRow() 641 | else: 642 | buf = "" 643 | for node in nodes: 644 | buf += self._deckRow(node, depth, len(nodes)) 645 | if depth == 0: 646 | buf += self._topLevelDragRow() 647 | end = time.time() 648 | return buf 649 | 650 | 651 | # based on Anki 2.0.45 aqt/main.py AnkiQt.onRefreshTimer 652 | def onRefreshTimer(): 653 | if mw.state == "deckBrowser": 654 | mw.deckBrowser._renderPage() # was refresh, but we're disabling that 655 | -------------------------------------------------------------------------------- /printing.py: -------------------------------------------------------------------------------- 1 | def cap(n): 2 | """The number. Either n, or capped according to cap value""" 3 | capValue = getUserOption("cap value", 0) 4 | if capValue == 0: 5 | if n == 0: 6 | return "0" 7 | else: 8 | return "+" 9 | if n >= capValue and capValue > 0: 10 | return str(c) + "+" 11 | return str(n) 12 | 13 | 14 | def conditionString(cond, string=None, parenthesis=False): 15 | """If the condition cond holds: return the string if it's not None, else the cond. 16 | If its not empty, add parenthesis around them 17 | """ 18 | if not cond: 19 | return "" 20 | if string is not None: 21 | ret = str(string) 22 | else: 23 | ret = str(cond) 24 | if parenthesis: 25 | ret = f"(+{ret})" 26 | return ret 27 | 28 | 29 | def nowLater(first, second=None): 30 | """A representation for the pair""" 31 | first = conditionString(first) 32 | second = conditionString(second, parenthesis=True) 33 | return first+second 34 | -------------------------------------------------------------------------------- /strings.py: -------------------------------------------------------------------------------- 1 | from anki.lang import _ 2 | from anki.stats import * 3 | 4 | from .config import getUserOption 5 | 6 | # Associate each column to its title 7 | defaultHeader = {**{ 8 | "cards seen today": _("Today"), 9 | "learning card": _("Learning")+"
"+_("(card)"), 10 | "learning later": _("Learning")+"
"+_("later")+" ("+_("review")+")", 11 | "learning now": _("Learning")+"
"+_("now"), 12 | "learning today": _("Learning")+"
"+_("now")+"
"+_("and later"), 13 | "learning all": _("Learning")+"
"+_("now")+"
("+_("later today")+"
("+_("other day")+"))", 14 | "review due": _("Due")+"
"+_("all"), 15 | "due tomorrow": _("Due")+"
"+_("tomorrow"), 16 | "review today": _("Due")+"
"+_("today"), 17 | "review": _("Due")+"
"+_("today")+" ("+_("all")+")", 18 | "unseen": _("Unseen")+"
"+_("all"), 19 | "unseen later": _("Unseen")+"
"+_("later"), 20 | "review later": _("review")+"
"+_("later"), 21 | "reviewed today": _("reviewed")+"
"+_("today"), 22 | "reviewed today/repeated today": _("reviewed")+"/"+"
"+_("repeated")+"
"+_("today"), 23 | "repeated today": _("repeated")+"
"+_("today"), 24 | "repeated": _("repeated"), 25 | "new": _("New")+"
"+_("today"), 26 | "unseen new": _("New")+"
"+"("+_("Unseen")+")", 27 | "buried": _("Buried"), 28 | "buried/suspended": _("Buried")+"/
"+_("Suspended"), 29 | "suspended": _("Suspended"), 30 | "cards": _("Total"), 31 | "notes/cards": _("Total")+"/
"+_("Card/Note"), 32 | "notes": _("Total")+"
"+_("Note"), 33 | "new today": _("New")+"
"+_("Today"), 34 | "today": _("Today"), 35 | "undue": _("Undue"), 36 | "mature": _("Mature"), 37 | "mature/young": _("Mature")+"/
"+_("Young"), 38 | "young": _("Young"), 39 | "marked": _("Marked"), 40 | "leech": _("Leech"), 41 | "bar": _("Progress"), 42 | "flags": _("Flags"), 43 | "all flags": _("Flags") 44 | }, **{f"flag {i}": _("Flag")+" {i}" for i in range(5)}} 45 | 46 | 47 | def getHeader(conf): 48 | """The header for the configuration in argument""" 49 | if "header" not in conf: 50 | return None 51 | header = conf["header"] 52 | if header is None: 53 | return defaultHeader[conf["name"]] 54 | return header 55 | 56 | 57 | # Associate each column to its overlay 58 | defaultOverlay = {**{ 59 | "cards seen today": _("Cards seen today")+"
"+_("""cards you'll see today which are not new"""), 60 | "learning card": _("Cards in learning")+"
"+_("""(either new cards you see again,""")+"
"+_("or cards which you have forgotten recently.")+"
"+_("""Assuming those cards didn't graduated)"""), 61 | "learning later": _("Review which will happen later.")+"
"+_("Either because a review happened recently,")+"
"+_("or because the card have many review left."), 62 | "learning now": _("Cards in learning which are due now.")+"
"+_("If there are no such cards,")+"
"+_("the time in minutes")+"
"+_("or seconds until another learning card is due"), 63 | "learning today": _("Cards in learning which are due now and then later."), 64 | "learning all": _("Cards in learning which are due now")+"
"+_("(and in parenthesis, the number of reviews")+"
"+_("which are due later)"), 65 | "review due": _("Review cards which are due today")+"
"+_("(not counting the one in learning)"), 66 | "due tomorrow": _("Review cards which are due tomorrow")+"
"+_("(note: new cards and lapsed card seen today may increase this number.)"), 67 | "review today": _("Review cards you will see today"), 68 | "review": _("Review cards cards you will see today")+"
"+_("(and the ones you will not see today)"), 69 | "unseen": _("Cards that have never been answered"), 70 | "unseen later": _("Cards that have never been answered
and you won't see today"), 71 | "review later": _("Cards that you must review,
but can't review now"), 72 | "reviewed today": _("Number of time
you did review a card from this deck."), 73 | "reviewed today/repeated today": _("Number of cards and of review
from this deck today."), 74 | "repeated today": _("Number of time you saw a question
from this deck today."), 75 | "repeated": _("Number of time
you saw a question from this deck."), 76 | "new": _("Unseen") + _("cards") + _("you will see today")+"
"+_("(what anki calls ")+_("new cards"), 77 | "unseen new": _("Unseen cards you will see today")+"
"+_("(and those you will not see today)"), 78 | "buried": _("number of buried cards,")+"
"+_("(cards you decided not to see today)"), 79 | "buried/suspended": _("number of buried cards,")+"
"+_("(cards you decided not to see today)")+_("number of suspended cards,")+"
"+_("(cards you will never see")+"
"+_("unless you unsuspend them in the browser)"), 80 | "suspended": _("number of suspended cards,")+"
"+_("(cards you will never see")+"
"+_("unless you unsuspend them in the browser)"), 81 | "cards": _("Number of cards in the deck"), 82 | "notes/cards": _("Number of cards/note in the deck"), 83 | "notes": _("Number of cards/note in the deck"), 84 | "today": _("Number of review you will see today")+"
"+_("(new, review and learning)"), 85 | "undue": _("Number of cards reviewed, not yet due"), 86 | "mature/young": _("Number of cards reviewed,")+"
"+_("with interval at least 3 weeks/")+"
"+_("less than 3 weeks"), 87 | "mature": _("Number of cards reviewed,")+"
"+_("with interval at least 3 weeks"), 88 | "young": _("Number of cards reviewed,")+"
"+_("with interval less than 3 weeks"), 89 | "marked": _("Number of marked note"), 90 | "leech": _("Number of note with a leech card"), 91 | "new today": _("Number of new cards you'll see today"), 92 | "bar": None, # It provides its own overlays, 93 | "flags": _("Number of cards for each flag"), 94 | "all flags": _("Number of cards for each flag") 95 | }, **{f"flag {i}": _(f"Number of cards with flag {i}") for i in range(5)}} 96 | 97 | 98 | def getOverlay(conf): 99 | """The overlay for the configuration in argument""" 100 | overlay = conf.get("overlay") 101 | if overlay is None: 102 | name = conf["name"] 103 | return defaultOverlay[name] 104 | return overlay 105 | 106 | 107 | def getColor(conf): 108 | if "color" in conf and conf.get('color') is not None: 109 | return conf.get('color') 110 | name = conf.get('name', "") 111 | for word, color in [ 112 | ("learning", colRelearn), 113 | ("unseen", colUnseen), 114 | ("new", colLearn), 115 | ("suspend", colSusp), 116 | ("young", colYoung), 117 | ("mature", colMature), 118 | ("buried", colSusp), 119 | ("repeated", colCum) 120 | ]: 121 | if word in name: 122 | return color 123 | return getUserOption("default column color", "grey") 124 | -------------------------------------------------------------------------------- /tree.py: -------------------------------------------------------------------------------- 1 | from anki.utils import intTime 2 | from aqt import mw 3 | 4 | from .consts import * 5 | from .debug import debug 6 | 7 | # Associate [column name][deck id name] to some value corresponding to 8 | # the number of card of this deck in this column 9 | values = dict() 10 | 11 | 12 | def computeValues(): 13 | debug("Compute values") 14 | cutoff = intTime() + mw.col.get_config('collapseTime') 15 | today = mw.col.sched.today 16 | tomorrow = today+1 17 | yesterdayLimit = (mw.col.sched.dayCutoff-86400)*1000 18 | debug(f"Yesterday limit is {yesterdayLimit}") 19 | queriesCardCount = ([(f"flag {i}", f"(flags & 7) == {i}", "", "") for i in range(5)] + 20 | [ 21 | ("due tomorrow", f"queue in ({QUEUE_REV},{QUEUE_DAY_LRN}) and due = {tomorrow}", "", ""), 22 | ("learning now from today", f"queue = {QUEUE_LRN} and due <= {cutoff}", "", ""), 23 | ("learning today from past", f"queue = {QUEUE_DAY_LRN} and due <= {today}", "", ""), 24 | ("learning later today", f"queue = {QUEUE_LRN} and due > {cutoff}", "", ""), 25 | ("learning future", f"queue = {QUEUE_DAY_LRN} and due > {today}", "", ""), 26 | ("learning today repetition from today", f"queue = {QUEUE_LRN}", f"left/1000", ""), 27 | ("learning today repetition from past", f"queue = {QUEUE_DAY_LRN}", f"left/1000", ""), 28 | ("learning repetition from today", f"queue = {QUEUE_LRN}", f"mod%1000", ""), 29 | ("learning repetition from past", f"queue = {QUEUE_DAY_LRN}", f"mod%1000", ""), 30 | ("review due", f"queue = {QUEUE_REV} and due <= {today}", "", ""), 31 | ("reviewed today", f"queue = {QUEUE_REV} and due>0 and due-ivl = {today}", "", ""), 32 | ("repeated today", f"revlog.id>{yesterdayLimit}", "", "revlog inner join cards on revlog.cid = cards.id"), 33 | ("repeated", "", "", f"revlog inner join cards on revlog.cid = cards.id"), 34 | ("unseen", f"queue = {QUEUE_NEW_CRAM}", "", ""), 35 | ("buried", f"queue = {QUEUE_USER_BURIED} or queue = {QUEUE_SCHED_BURIED}", "", ""), 36 | ("suspended", f"queue = {QUEUE_SUSPENDED}", "", ""), 37 | ("cards", "", "", ""), 38 | ("undue", f"queue = {QUEUE_REV} and due > {today}", "", ""), 39 | ("mature", f"queue = {QUEUE_REV} and ivl >= 21", "", ""), 40 | ("young", f"queue = {QUEUE_REV} and 0