Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git
M installer
110110
  local -r path_jdk="/tmp/${file_jdk}"
111111
112
  if [ ! -f ${path_jdk} ]; then
113
    $log "Download ${url_jdk}"
112
  # File must have contents.
113
  if [ ! -s ${path_jdk} ]; then
114
    $log "Download ${url_jdk} to ${path_jdk}"
114115
    wget -q "${url_jdk}" -O "${path_jdk}"
115116
  fi
M src/main/java/com/scrivenvar/Main.java
104104
105105
    stage.show();
106
107
    // After the stage is visible, the panel dimensions are known, which
108
    // allows scaling images to fit the preview panel.
109
    getMainWindow().init();
106110
  }
107111
M src/main/java/com/scrivenvar/MainWindow.java
203203
204204
  public MainWindow() {
205
    sNotifier.addObserver( this );
206
205207
    mStatusBar = createStatusBar();
206208
    mLineNumberText = createLineNumberText();
207209
    mFindTextField = createFindTextField();
208210
    mScene = createScene();
209211
    mSpellChecker = createSpellChecker();
210212
213
    // Add the close request listener before the window is shown.
211214
    initLayout();
215
  }
216
217
  /**
218
   * Called after the stage is shown.
219
   */
220
  public void init() {
212221
    initFindInput();
213222
    initSnitch();
214223
    initDefinitionListener();
215224
    initTabAddedListener();
216225
    initTabChangedListener();
217226
    initPreferences();
218227
    initVariableNameInjector();
219
220
    sNotifier.addObserver( this );
221228
  }
222229
...
411418
    editorPane.addTabSelectionListener(
412419
        ( tabPane, oldTab, newTab ) -> {
413
          // Clear the preview pane when closing an editor. When the last
414
          // tab is closed, this ensures that the preview pane is empty.
415420
          if( newTab == null ) {
421
            // Clear the preview pane when closing an editor. When the last
422
            // tab is closed, this ensures that the preview pane is empty.
416423
            getPreviewPane().clear();
417424
          }
418
419
          // If there was no old tab, then this is a first time load, which
420
          // can be ignored.
421
          if( oldTab != null ) {
422
            if( newTab != null ) {
423
              final FileEditorTab tab = (FileEditorTab) newTab;
424
              updateVariableNameInjector( tab );
425
              process( tab );
426
            }
425
          else {
426
            final var tab = (FileEditorTab) newTab;
427
            updateVariableNameInjector( tab );
428
            process( tab );
427429
          }
428430
        }
...
435437
  private void initPreferences() {
436438
    initDefinitionPane();
437
    final var editor = getFileEditorPane();
438
    editor.initPreferences();
439
    final var tab = editor.newEditor();
440
441
    // This is a bonafide hack to ensure the preview panel scales any images
442
    // to fit the panel width. The preview panel width isn't known until after
443
    // the main window is displayed. However, these preferences are initialized
444
    // prior to showing the main window. The preferences include loading the
445
    // text for an editor, which then parses it. Upon parsing, the width of
446
    // the preview pane is a negative (invalid) value. By waiting to load the
447
    // editors until after the main window is shown, a valid preview panel
448
    // width can be determined and thus the images scaled to fit.
449
    //
450
    // To avoid this hack, the preferences need to be loaded separately from
451
    // opening the editors. Those preferences can be used to get the window
452
    // sizes for showing the main window. Once the main window is shown, all
453
    // the subsequent initializations can take place.
454
    addShowListener( editor, ( __ ) -> {
455
      editor.closeEditor( tab, false );
456
      editor.initPreferences();
457
    } );
439
    getFileEditorPane().initPreferences();
458440
  }
459441
M src/main/java/com/scrivenvar/decorators/RVariableDecorator.java
4141
  public static final char SUFFIX = '`';
4242
43
  private final String mDelimiterBegan;
44
  private final String mDelimiterEnded;
45
46
  public RVariableDecorator() {
47
    final var prefs = getUserPreferences();
48
    mDelimiterBegan = prefs.getRDelimiterBegan();
49
    mDelimiterEnded = prefs.getRDelimiterEnded();
50
  }
43
  private final String mDelimiterBegan =
44
      getUserPreferences().getRDelimiterBegan();
45
  private final String mDelimiterEnded =
46
      getUserPreferences().getRDelimiterEnded();
5147
5248
  /**
M src/main/java/com/scrivenvar/preview/CustomImageLoader.java
2828
package com.scrivenvar.preview;
2929
30
import com.scrivenvar.util.ProtocolResolver;
3031
import javafx.beans.property.IntegerProperty;
3132
import javafx.beans.property.SimpleIntegerProperty;
...
7374
   *
7475
   * @param uri    Path to the image resource to load.
75
   * @param width  Maximum image width (scaled to fit), in pixels.
76
   * @param height Image height, in pixels.
76
   * @param width  Ignored.
77
   * @param height Ignored.
7778
   * @return The scaled image, or a placeholder image if the URI's content
7879
   * could not be retrieved.
...
8586
    assert height >= 0;
8687
87
    boolean exists;
88
    boolean exists = true;
8889
8990
    try {
90
      exists = Files.exists( Paths.get( new URI( uri ) ) );
91
      final String protocol = ProtocolResolver.getProtocol( uri );
92
93
      if( "file".equals( protocol ) ) {
94
        exists = Files.exists( Paths.get( new URI( uri ) ) );
95
      }
9196
    } catch( final Exception e ) {
9297
      exists = false;
...
102107
   *
103108
   * @param uri Path to the image file to load.
104
   * @param w   Unused (usually -1, which is useless).
105
   * @param h   Unused (ditto).
109
   * @param w   Ignored.
110
   * @param h   Ignored.
106111
   * @return Resource representing the rendered image and path.
107112
   */
M src/main/java/com/scrivenvar/preview/HTMLPreviewPane.java
134134
     */
135135
    private void setWidth( final ComponentEvent e ) {
136
      final int width = (int) (e.getComponent().getWidth() * .9);
136
      final int width = (int) (e.getComponent().getWidth() * .95);
137137
      HTMLPreviewPane.this.mImageLoader.widthProperty().set( width );
138138
    }
M src/main/java/com/scrivenvar/processors/markdown/ImageLinkExtension.java
105105
    private ResolvedLink resolve( final ResolvedLink link ) {
106106
      String url = link.getUrl();
107
      final String protocol = ProtocolResolver.getProtocol( url );
107108
108109
      try {
109110
        // If the direct file name exists, then use it directly.
110
        if( Path.of( url ).toFile().exists() ) {
111
        if( ("file".equals( protocol ) && Path.of( url ).toFile().exists()) ||
112
            protocol.startsWith( "http" ) ) {
111113
          return valid( link, url );
112114
        }
...
151153
        }
152154
153
        final String protocol = ProtocolResolver.getProtocol( url );
154155
        if( "file".equals( protocol ) ) {
155156
          url = "file://" + url;