anki/rslib/src/lib.rs

53 lines
944 B
Rust
Raw Normal View History

2020-01-10 12:00:48 +01:00
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
2020-01-29 04:17:20 +01:00
#![deny(unused_must_use)]
Simplify note adding and the deck/notetype choosers The existing code was really difficult to reason about: - The default notetype depended on the selected deck, and vice versa, and this logic was buried in the deck and notetype choosing screens, and models.py. - Changes to the notetype were not passed back directly, but were fired via a hook, which changed any screen in the app that had a notetype selector. It also wasn't great for performance, as the most recent deck and tags were embedded in the notetype, which can be expensive to save and sync for large notetypes. To address these points: - The current deck for a notetype, and notetype for a deck, are now stored in separate config variables, instead of directly in the deck or notetype. These are cheap to read and write, and we'll be able to sync them individually in the future once config syncing is updated in the future. I seem to recall some users not wanting the tag saving behaviour, so I've dropped that for now, but if people end up missing it, it would be simple to add as an extra auxiliary config variable. - The logic for getting the starting deck and notetype has been moved into the backend. It should be the same as the older Python code, with one exception: when "change deck depending on notetype" is enabled in the preferences, it will start with the current notetype ("curModel"), instead of first trying to get a deck-specific notetype. - ModelChooser has been duplicated into notetypechooser.py, and it has been updated to solely be concerned with keeping track of a selected notetype - it no longer alters global state.
2021-03-08 14:23:24 +01:00
pub mod adding;
2019-12-24 23:59:33 +01:00
pub mod backend;
2020-05-26 09:18:50 +02:00
mod backend_proto;
pub mod browser_table;
2020-03-17 03:33:29 +01:00
pub mod card;
pub mod cloze;
pub mod collection;
pub mod config;
pub mod dbcheck;
2021-04-20 13:54:24 +02:00
pub mod deckconfig;
pub mod decks;
2021-04-01 08:06:24 +02:00
pub mod error;
2020-05-05 12:50:17 +02:00
pub mod findreplace;
pub mod i18n;
pub mod latex;
pub mod links;
pub mod log;
mod markdown;
pub mod media;
pub mod notes;
pub mod notetype;
2021-03-13 11:10:03 +01:00
pub mod ops;
mod preferences;
2020-05-26 09:18:50 +02:00
pub mod prelude;
2020-05-30 12:21:44 +02:00
pub mod revlog;
2021-02-23 05:36:30 +01:00
pub mod scheduler;
2020-03-15 10:11:45 +01:00
pub mod search;
2020-03-30 06:39:46 +02:00
pub mod serde;
mod stats;
pub mod storage;
2020-05-26 09:18:50 +02:00
mod sync;
pub mod tags;
pub mod template;
2020-01-10 12:04:52 +01:00
pub mod template_filters;
2020-01-10 12:01:23 +01:00
pub mod text;
pub mod timestamp;
pub mod types;
2020-03-29 09:52:16 +02:00
pub mod undo;
2020-05-26 09:18:50 +02:00
pub mod version;
use std::env;
use lazy_static::lazy_static;
lazy_static! {
pub(crate) static ref PYTHON_UNIT_TESTS: bool = env::var("ANKI_TEST_MODE").is_ok();
}