Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Revisit autoinsert algorithm, add messages when inserting

AuthorDaveJarvis <email>
Date2020-09-13 20:43:04 GMT-0700
Commit3feea598e9c2b5c1cde530a341919fac06551a3d
Parent4dfb9fa
Delta50 lines added, 32 lines removed, 18-line increase
src/main/resources/com/scrivenvar/messages.properties
Main.menu.insert=_Insert
-Main.menu.insert.bold=Bold
-Main.menu.insert.italic=Italic
-Main.menu.insert.superscript=Superscript
-Main.menu.insert.subscript=Subscript
-Main.menu.insert.strikethrough=Strikethrough
-Main.menu.insert.blockquote=Blockquote
-Main.menu.insert.code=Inline Code
-Main.menu.insert.fenced_code_block=Fenced Code Block
+Main.menu.insert.blockquote=_Blockquote
+Main.menu.insert.code=Inline _Code
+Main.menu.insert.fenced_code_block=_Fenced Code Block
Main.menu.insert.fenced_code_block.prompt=Enter code here
-Main.menu.insert.link=Link...
-Main.menu.insert.image=Image...
-Main.menu.insert.heading.1=Heading 1
+Main.menu.insert.link=_Link...
+Main.menu.insert.image=_Image...
+Main.menu.insert.heading.1=Heading _1
Main.menu.insert.heading.1.prompt=heading 1
-Main.menu.insert.heading.2=Heading 2
+Main.menu.insert.heading.2=Heading _2
Main.menu.insert.heading.2.prompt=heading 2
-Main.menu.insert.heading.3=Heading 3
+Main.menu.insert.heading.3=Heading _3
Main.menu.insert.heading.3.prompt=heading 3
-Main.menu.insert.unordered_list=Unordered List
-Main.menu.insert.ordered_list=Ordered List
-Main.menu.insert.horizontal_rule=Horizontal Rule
+Main.menu.insert.unordered_list=_Unordered List
+Main.menu.insert.ordered_list=_Ordered List
+Main.menu.insert.horizontal_rule=_Horizontal Rule
-Main.menu.view=_View
-Main.menu.view.refresh=Refresh
+Main.menu.format=Forma_t
+Main.menu.format.bold=_Bold
+Main.menu.format.italic=_Italic
+Main.menu.format.superscript=Su_perscript
+Main.menu.format.subscript=Su_bscript
+Main.menu.format.strikethrough=Stri_kethrough
+
+Main.menu.definition=_Definition
+Main.menu.definition.create=_Create
+Main.menu.definition.insert=_Insert
Main.menu.help=_Help
Main.menu.help.about=About ${Main.title}
# ########################################################################
# Status Bar
# ########################################################################
-Main.statusbar.text.offset=offset
-Main.statusbar.line=Line {0} of {1}, ${Main.statusbar.text.offset} {2}
-Main.statusbar.state.default=OK
-Main.statusbar.parse.error={0} (near ${Main.statusbar.text.offset} {1})
+Main.status.text.offset=offset
+Main.status.line=Line {0} of {1}, ${Main.status.text.offset} {2}
+Main.status.state.default=OK
+Main.status.error.parse={0} (near ${Main.status.text.offset} {1})
+Main.status.error.def.blank=Move the caret to a word before inserting a definition.
+Main.status.error.def.empty=Create a definition before inserting a definition.
+Main.status.error.def.missing=No definition value found for ''{0}''.
+Main.status.error.r=Error with [{0}...]: {1}
# ########################################################################
src/main/java/com/scrivenvar/preview/SvgRasterizer.java
try {
return rasterize( new URL( url ), width );
- } catch( final Exception e ) {
- alert( e );
+ } catch( final Exception ex ) {
+ alert( ex );
return BROKEN_IMAGE_PLACEHOLDER;
}
final var width = root.getAttribute( "width" );
return rasterize( document, INT_FORMAT.parse( width ).intValue() );
- } catch( final Exception e ) {
- alert( e );
+ } catch( final Exception ex ) {
+ alert( ex );
return BROKEN_IMAGE_PLACEHOLDER;
}
final var width = root.getAttribute( "width" );
return rasterizeString( xml, INT_FORMAT.parse( width ).intValue() );
- } catch( final Exception e ) {
- alert( e );
+ } catch( final Exception ex ) {
+ alert( ex );
return BROKEN_IMAGE_PLACEHOLDER;
}
src/main/java/com/scrivenvar/preview/SvgReplacedElementFactory.java
}
else if( HTML_TEX.equals( nodeName ) ) {
- // Convert the <svg> element to a raster graphic if it isn't cached.
+ // Convert the <svg> element to a raster graphic if not yet cached.
final var src = e.getTextContent();
image = getCachedImage(
src/main/java/com/scrivenvar/StatusBarNotifier.java
* Updates the status bar with a custom message.
*
- * @param msg A notification to show the user (typically an error).
+ * @param key The resource bundle key associated with a message (typically
+ * to inform the user about an error).
*/
- public static void alert( final String msg ) {
- update( msg );
+ public static void alert( final String key ) {
+ update( get( key ) );
+ }
+
+ /**
+ * Updates the status bar with a custom message.
+ *
+ * @param key The property key having a value to populate with arguments.
+ * @param args The placeholder values to substitute into the key's value.
+ */
+ public static void alert( final String key, final Object... args ) {
+ update( get( key, args ) );
}