Module: AnkiConnect::Client::Graphical
- Included in:
- AnkiConnect::Client
- Defined in:
- lib/anki_connect/graphical.rb
Overview
Methods to interact with Anki’s GUI windows and dialogs (card browser, review screen, editing interfaces).
Instance Method Summary collapse
-
#gui_add_cards(note) ⇒ Integer
Opens Add Cards dialog with preset values.
-
#gui_add_note_set_data(note, append: false) ⇒ Boolean
Sets fields/tags/deck/model in open Add Note dialog.
-
#gui_answer_card(ease) ⇒ Boolean
Answers the current card.
-
#gui_browse(query, reorder_cards: nil) ⇒ Array<Integer>
Opens Card Browser dialog and searches for query.
-
#gui_check_database ⇒ Boolean
Requests database check.
-
#gui_current_card ⇒ Hash?
Gets information about current card in review.
-
#gui_deck_browser ⇒ nil
Opens Deck Browser dialog.
-
#gui_deck_overview(name) ⇒ Boolean
Opens Deck Overview dialog for a deck.
-
#gui_deck_review(name) ⇒ Boolean
Starts review for a deck.
-
#gui_edit_note(note_id) ⇒ nil
Opens Edit dialog for a note.
-
#gui_exit_anki ⇒ nil
Schedules graceful Anki shutdown.
-
#gui_import_file(path: nil) ⇒ nil
Opens Import dialog with optional file path.
-
#gui_play_audio ⇒ Boolean
Plays audio for current card side.
-
#gui_select_card(card_id) ⇒ Boolean
Selects a card in the open Card Browser.
-
#gui_selected_notes ⇒ Array<Integer>
Gets selected notes from open Card Browser.
-
#gui_show_answer ⇒ Boolean
Shows answer side of current card.
-
#gui_show_question ⇒ Boolean
Shows question side of current card.
-
#gui_start_card_timer ⇒ Boolean
Starts/resets timer for current card.
-
#gui_undo ⇒ Boolean
Undoes last action/card.
Instance Method Details
#gui_add_cards(note) ⇒ Integer
Opens Add Cards dialog with preset values. Multiple invocations close old window and reopen with new values.
39 40 41 |
# File 'lib/anki_connect/graphical.rb', line 39 def gui_add_cards(note) request(:guiAddCards, note: note) end |
#gui_add_note_set_data(note, append: false) ⇒ Boolean
Sets fields/tags/deck/model in open Add Note dialog. Returns error if Add Note dialog not open. Deck/model always replace; fields/tags respect append flag.
58 59 60 |
# File 'lib/anki_connect/graphical.rb', line 58 def gui_add_note_set_data(note, append: false) request(:guiAddNoteSetData, note: note, append: append) end |
#gui_answer_card(ease) ⇒ Boolean
Answers the current card. Answer must be displayed before answering.
96 97 98 |
# File 'lib/anki_connect/graphical.rb', line 96 def gui_answer_card(ease) request(:guiAnswerCard, ease: ease) end |
#gui_browse(query, reorder_cards: nil) ⇒ Array<Integer>
Opens Card Browser dialog and searches for query.
13 14 15 16 17 |
# File 'lib/anki_connect/graphical.rb', line 13 def gui_browse(query, reorder_cards: nil) params = { query: query } params[:reorderCards] = reorder_cards if reorder_cards request(:guiBrowse, **params) end |
#gui_check_database ⇒ Boolean
Requests database check. Returns immediately without waiting for check to complete.
153 154 155 |
# File 'lib/anki_connect/graphical.rb', line 153 def gui_check_database request(:guiCheckDatabase) end |
#gui_current_card ⇒ Hash?
Gets information about current card in review.
65 66 67 |
# File 'lib/anki_connect/graphical.rb', line 65 def gui_current_card request(:guiCurrentCard) end |
#gui_deck_browser ⇒ nil
Opens Deck Browser dialog.
118 119 120 |
# File 'lib/anki_connect/graphical.rb', line 118 def gui_deck_browser request(:guiDeckBrowser) end |
#gui_deck_overview(name) ⇒ Boolean
Opens Deck Overview dialog for a deck.
111 112 113 |
# File 'lib/anki_connect/graphical.rb', line 111 def gui_deck_overview(name) request(:guiDeckOverview, name: name) end |
#gui_deck_review(name) ⇒ Boolean
Starts review for a deck.
126 127 128 |
# File 'lib/anki_connect/graphical.rb', line 126 def gui_deck_review(name) request(:guiDeckReview, name: name) end |
#gui_edit_note(note_id) ⇒ nil
Opens Edit dialog for a note. Opens edit dialog with Preview, Browse, and navigation buttons.
48 49 50 |
# File 'lib/anki_connect/graphical.rb', line 48 def gui_edit_note(note_id) request(:guiEditNote, note: note_id) end |
#gui_exit_anki ⇒ nil
Schedules graceful Anki shutdown. Asynchronous - returns immediately without waiting for termination.
145 146 147 |
# File 'lib/anki_connect/graphical.rb', line 145 def gui_exit_anki request(:guiExitAnki) end |
#gui_import_file(path: nil) ⇒ nil
Opens Import dialog with optional file path. Opens file dialog if no path provided. Forward slashes required on Windows. Anki 2.1.52+ only.
135 136 137 138 139 |
# File 'lib/anki_connect/graphical.rb', line 135 def gui_import_file(path: nil) params = {} params[:path] = path if path request(:guiImportFile, **params) end |
#gui_play_audio ⇒ Boolean
Plays audio for current card side.
160 161 162 |
# File 'lib/anki_connect/graphical.rb', line 160 def gui_play_audio request(:guiPlayAudio) end |
#gui_select_card(card_id) ⇒ Boolean
Selects a card in the open Card Browser.
23 24 25 |
# File 'lib/anki_connect/graphical.rb', line 23 def gui_select_card(card_id) request(:guiSelectCard, card: card_id) end |
#gui_selected_notes ⇒ Array<Integer>
Gets selected notes from open Card Browser.
30 31 32 |
# File 'lib/anki_connect/graphical.rb', line 30 def gui_selected_notes request(:guiSelectedNotes) end |
#gui_show_answer ⇒ Boolean
Shows answer side of current card.
87 88 89 |
# File 'lib/anki_connect/graphical.rb', line 87 def gui_show_answer request(:guiShowAnswer) end |
#gui_show_question ⇒ Boolean
Shows question side of current card.
80 81 82 |
# File 'lib/anki_connect/graphical.rb', line 80 def gui_show_question request(:guiShowQuestion) end |
#gui_start_card_timer ⇒ Boolean
Starts/resets timer for current card. Useful for accurate time tracking when displaying cards via API.
73 74 75 |
# File 'lib/anki_connect/graphical.rb', line 73 def gui_start_card_timer request(:guiStartCardTimer) end |
#gui_undo ⇒ Boolean
Undoes last action/card.
103 104 105 |
# File 'lib/anki_connect/graphical.rb', line 103 def gui_undo request(:guiUndo) end |