Transcript Editor

class TextEditor.PloverCATEditor(*args: Any, **kwargs: Any)

Bases: QTextEdit

Editor object for a transcript.

The editor is separated from the window, containing all transcript data, and settings that are unique to each transcript. No changes to the GUI, except those to the QTextEdit itself should be made here.

Variables:
  • new_openTrue if transcript in temporary directory

  • engine – Plover existing engine instance

  • config (dict) – transcript configuration

  • file_name – transcript directory path

  • repodulwich repository instance

  • backup_document (dict) – original transcript data, paragraph number: block data

  • tape (str) – transcript tape contents as a long string with new line separators

  • styles (dict) – transcript style parameters

  • txt_formats (dict) – QTextCharFormat objects for each style by name

  • par_formats (dict) – QTextBlockFormat objects for each style by name

  • highlight_colors (dict) – QColor objects for each element type

  • user_field_dict (dict) – dict ref of self.config["user_field_dict"]

  • auto_paragraph_affixes (dict) – dict ref of self.config["auto_paragraph_affixes"]

  • cursor_block (int) – block that current cursor was in on last stroke

  • cursor_block_position (int) – position in cursor_block of current cursor on last stroke

  • stroke_time (str) – time of last stroke

  • last_raw_steno (str) – last stroke

  • last_string_sent (str) – string sent by Plover on last stroke

  • last_backspaces_sent (int) – number of backspaces sent by Plover on last stroke

  • track_lengths (list) – deque of length 10 that tracks length of last_string_sent and last_backspaces_sent

  • undo_stackQUndoStack

  • spell_ignore (list) – words to ignore in spellcheck, session only

  • dictionaryspylls dictionary

  • dictionary_name – name of dictionary, usually the language code

  • audio_file – path to file being played/recorded

  • playerQMediaPlayer

  • media_recorderQMediaCaptureSession that manages audio input for recording

  • recorderQMediaCaptureSession attached to media_recorder

  • audio_position (int) – current position of media being played

  • audio_delay (int) – offset to subtract from audio_position

send_message

Signal to send with message to display.

alias of str

send_tape

Signal to send with tape contents.

alias of str

audio_position_changed

Signal to send with new audio position.

alias of int

audio_length_changed

Signal to send with new audio duration.

alias of int

setCompleter(c)

Set autocompletion for transcript.

completer()

Return completer.

textUnderCursor()

Return work under cursor.

showPossibilities()

Show autocompletion possibilities.

focusInEvent(e)

Set completer when in focus.

keyPressEvent(event)

Control and filter keyboard input

Parameters:

event – keyPressEvent

Normal letter keys have to be suppressed when Plover output is enabled. Same with Backspace key. Deletion is allowed even when output is enabled.

load(path, engine, load_transcript=True)

Load transcript and associated data.

The associated load_* methods will create necessary files if none exist.

Parameters:
  • path – path of transcript to load

  • engine – Plover engine instance

  • load_transcript (bool) – load transcript data, default True

load_transcript(transcript)

Load transcript steno data.

Parameters:

transcript – path to transcript file

load_tape()

Load tape data.

save()

Save transcript.

save_as(new_path)

Save transcript to new location.

Parameters:

new_path – directory path

save_transcript(path)

Extract transcript steno data and save.

Parameters:

path – transcript file path

autosave()

Save transcript data to backup file.

close_transcript(force=False)

Clean up transcript for close.

Parameters:

force (bool) – force close, even if unsaved changes exist

clear_transcript()

Clears all transcript data.

dulwich_save(message='autosave')

Commit transcript files to dulwich repo.

Parameters:

message (str) – commit message

get_dulwich_commits()

Get most recent commits from dulwich repo.

revert_transcript(commit_id)

Revert transcript to previous commit based on commit id.

load_config_file(path, engine=None)

Load transcript configuration.

save_config_file(config_path=None)

Save configuration file.

Parameters:

config_path – path to save configuration

get_config_value(key)

Get configuration value by key.

set_config_value(key, value)

Set configuration value by key.

load_spellcheck_dict(dic_path='en_US')

Load spellchecking dictionary for spylls.

Parameters:

dic_path (str) – language code or path to dic files

load_dicts(engine, dictionaries=None)

Load dictionaries for transcript.

Note that loading dictionaries is not an undo-able action at this point.

Parameters:

dictionaries (list) – paths to dictionary files

add_dict(dictionary)

Add dictionary to transcript.

Parameters:

dictionary – path string for dictionary to add

restore_dictionary_from_backup(engine)

Restore dictionaries from backup file.

Parameters:

engine – Plover engine instance

get_highlight_colors()

Obtain element highlight colors from saved settings.

load_check_styles(path)

Load a style JSON or ODF file.

Parameters:

path – path to style file.

gen_style_formats()

Generate QText*Format objects from style dictionary.

set_style_property(name, attribute, value, paragraph=False, text=False)

Set a style attribute given name, and type of property.

Parameters:
  • name (str) – name of style

  • attribute (str) – attribute to set

  • value (str) – new value for attribute

  • paragraph (bool) – set attribute in “paragraphproperties”

  • text (bool) – set attribute in “textproperties”

set_style_properties(name, properties)

Set all attributes for a style.

Parameters:
  • name (str) – name of style

  • properties (dict) – style attributes

get_style_property(name, attribute, paragraph=False, text=False)

Get style attribute. :param str name: style name :param str attribute: style attribute :param bool paragraph: obtain attribute from paragraphproperties :param bool text: obtain attribute from textproperties

set_paragraph_style(style, block=None)

Set style of paragraph in transcript.

Parameters:
  • style (str) – name of style

  • block (int) – paragraph block number

set_paragraph_property(paragraph, prop, value)

Set a paragraph’s property.

Parameters:
  • paragraph (int) – paragraph block number

  • prop (str) – property name

  • value – value

refresh_par_style(block=None)

Update a paragraph’s display styling.

Parameters:

blockQTextBlock instance

save_style_file()

Save current styles to style file.

to_next_style()

Set current paragraph style based on previous style. #todo change to using block number rather than taking cursor

on_stroke(stroke_pressed, end=False)

Write.

Parameters:
  • stroke_pressed – stroke sent to Plover

  • end (bool) – always append writing to end of transcript

log_to_tape(stroke)

Log stroke to transcript tape.

Parameters:

stroke – stroke to log

update_block_times(block, edit_time)

Update paragraph timestamps.

Parameters:
  • block – reference to a QTextBlock

  • edit_time

merge_paragraphs(add_space=True)

Merge two paragraphs.

Parameters:

add_space (bool) – add space between paragraph when merging

split_paragraph(remove_space=True)

Split one paragraph into two.

Parameters:

remove_space (bool) – remove space from beginning of new second paragraph if exist

cut_steno(store=True, cut=True)

Remove selected text and steno.

Parameters:
  • store (bool) – store removed data

  • cut (bool) – whether cut or paste action, for message display

replace(steno='', replace_term=None)

Replace selected text with stroke element.

Parameters:
  • steno (str) – stroke for stroke element

  • replace_term (str) – text for stroke element, the replacement text

mock_del()

Delete selection or one character after cursor.

insert_text(text=None)

Insert text at cursor.

Parameters:

text (list) – list of text to insert

insert_field(name)

Insert field at cursor.

insert_image(img_path)

Insert image at cursor.

Parameters:

img_path – path to image

update_fields(new_field_dict)

Update existing field elements with new values.

Parameters:

new_field_dict (dict) – updated field dict

extract_indexes()

Extract existing index entries from transcript.

Returns:

dictionary of indices with nested entries

insert_index_entry(el)

Insert index entry at cursor.

Parameters:

el – index entry element

update_indices(old, new)

Update all index entries.

Parameters:
  • old (dict) – existing indices data

  • new (dict) – new indices data

add_begin_auto_affix(element, style)

Add paragraph prefix based on style.

Parameters:
  • element – element to add affix to

  • style – style for paragraph element is from

Returns:

new element, now automatic

add_end_auto_affix(element, style)

Add paragraph suffix based on style.

Parameters:
  • element – element to add affix to

  • style – style for paragraph element is from

Returns:

new element, now automatic

insert_autocomplete(index)

Insert selected autocomplete candidate.

Parameters:

index (int) – index of selection from pop-up widget

mock_type(text)

Mock typing from keyboard.

Parameters:

text (str) – text to insert

mock_bks()

Mock one backspace.

navigate_to(block_number)

Move cursor to beginning of a block by number.

Parameters:

block_number (int) – paragraph number to move to

get_audio_time(convert=True)

Get audio time from media.

Parameters:

convert (bool) – convert to str timestamp

Returns:

timestamp if convert = True, or milliseconds if False

set_audio_time(milliseconds)

Set media playback position

Parameters:

milliseconds (int) – position

load_audio(path)

Load media file.

Parameters:

path (str) – path to media file

play_pause_audio()

Play or pause media.

update_audio_duration(duration)

Send new duration to GUI.

Parameters:

duration (int) – media duration

update_audio_position(position)

Send new position in media.

Parameters:

position (int) – media position

get_audio_timestamp_position()

Get preceding audio timestamp by cursor position