A yWriter file viewer

126 views
Skip to first unread message

Peter T.

unread,
Jan 19, 2022, 7:44:09 AM1/19/22
to yWriter
Here is a fast file viewer for yWriter projects, written in Python:

https://peter88213.github.io/yw-viewer/

I wrote it mainly for Linux, where yWriter takes quite a long time to start. But it also works under other operating systems. Handy for a quick look at the project without changing anything in the project folder.

Have fun with it, 
Peter 

Simon Haynes

unread,
Jan 19, 2022, 7:59:34 AM1/19/22
to ywr...@googlegroups.com
Nice idea for a project!

One day I'm sure someone will figure out how to access LibYW7.dll - with that (plus LibSpacejock.dll) you can load a project, access the contents, etc.  You could even change it and save it back out.

Both are cross-platform dotnet standard 2.0 dlls.

Cheers
Simon



--
You received this message because you are subscribed to the Google Groups "yWriter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ywriter+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ywriter/65ddfd47-fe67-46ee-9915-99ab765decb7n%40googlegroups.com.


--

--
Visit Spacejock Software, the home of yWriter, FCharts and more
Visit spacejock.com.au for my articles on writing and publishing novels.

Peter T.

unread,
Jan 19, 2022, 1:11:10 PM1/19/22
to yWriter
On Wednesday, January 19, 2022 at 1:59:34 PM UTC+1 Simon Haynes wrote:
One day I'm sure someone will figure out how to access LibYW7.dll - with that (plus LibSpacejock.dll) you can load a project, access the contents, etc.  You could even change it and save it back out.

Both are cross-platform dotnet standard 2.0 dlls.

I'm sure fascinating things can be done with the dotnet dlls once the API is documented, but currently I haven't even managed to get yWriter to work under Mono.

With Python it is the "PyWriter" library, which creates an object tree from yw7 files, which can also be written back. 
I have given up yw5 and yw6 support in the meantime to keep the structure clearer (I had broken everything down into a bunch of strategy classes for the different file formats, for utf-8 and ANSI encoding, and for writing RTF files). 

Python code is executed sufficiently fast for text processing and does not cause any problems under Linux (as long as you don't use complex GUI kits such as QT5). There is also some open source novel writing software programmed in Python, e.g. Manuskript and novelWriter, but at present none of them can match yWriter.

Cheers, 
Peter 
 

Todd Carnes

unread,
Jan 19, 2022, 6:28:31 PM1/19/22
to ywr...@googlegroups.com
Linux can run .Net core 2.0 natively.
(https://dotnet.microsoft.com/en-us/download/dotnet/2.0)

Has anyone ever tried that?

One caveat, while they still have the runtimes and sdk available for
download, Microsoft no longer officially supports .Net 2.0. They are
encouraging Linux users to upgrade to either .NET Core 3.1, .NET 5 or
.NET 6.
(https://docs.microsoft.com/en-us/dotnet/core/install/linux?WT.mc_id=dotnet-35129-website)

Todd

Todd Carnes

unread,
Jan 19, 2022, 7:27:06 PM1/19/22
to ywr...@googlegroups.com
Never mind. I just tried it. I forgot they're CLI only right now.

Todd Carnes

unread,
Jan 19, 2022, 7:48:29 PM1/19/22
to ywr...@googlegroups.com

Screenshot of YWriter 7 running under Mono 6.12.0.122 with Mono-basic 4.7 (dnf install mono mono-basic) on Fedora 35. (Note, I did NOT do any significant testing of the program. I only tried to run it.)

On 1/19/2022 10:11 AM, Peter T. wrote:

Peter T.

unread,
Jan 20, 2022, 4:38:58 AM1/20/22
to yWriter
On Thursday, January 20, 2022 at 1:48:29 AM UTC+1 toddc wrote:

Screenshot of YWriter 7 running under Mono 6.12.0.122 with Mono-basic 4.7 (dnf install mono mono-basic) on Fedora 35. 

What a beautiful screenshot. Unfortunately, I get nothing but a blunt error message when trying to start yWriter7.exe under mono on xubuntu: 

~/yWriter7/bin$ mono yWriter7.exe

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

 
Obviously, visual Basic support is missing on my box. Web search leads me to the Mono website, where it is claimed that

> "The Visual Basic runtime has been available for Mono for a while, and with the release of Mono 1.2.3, the Visual Basic support is complete, with the introduction of a self-hosting compiler and class libraries for Visual Basic development on any of the Mono supported systems."

Then they point to their downloads page where you can download what I already have installed. 
There's also a mono-basic project on GitHub without much documentation, just referring to the Mono web site mentioned before.
Then you can spend days on forums and mailing lists being told that you're just too stupid to compile everything from source code. 
It's the old Linux malaise that makes me want to stick with Windows as long as possible. 

Anyway, a Python script is quick to program, and that is the real topic of this thread.

Cheers, 
Peter 

Simon Haynes

unread,
Jan 20, 2022, 4:55:10 AM1/20/22
to ywr...@googlegroups.com
vbnc is the package, I believe



--
You received this message because you are subscribed to the Google Groups "yWriter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ywriter+u...@googlegroups.com.

Peter T.

unread,
Jan 20, 2022, 5:35:05 AM1/20/22
to yWriter
Ah -- thanks, Simon. Actually, the package is named mono-vbnc  and easy to install via apt. 
Thus, yWriter 7 could be started as well as yWriter 5. 
I loaded the yw5 sample project and failed to open a scene in both versions. 

screen01.png

If I'm not mistaken, other users experienced this as well. 
Moving chapters and scenes went somewhat unruly and with not clearly predictable result.
The RTF export seemed to work at first, but in the end there was no exported file.
Finally, yWriter crashed when I clicked on the desktop outside the program window. 

May the log be helpful:

~/yWriter7/bin$ mono yWriter7.exe
11:08:01 Connecting WINDOWS Rtf handler in LibSpacejockWin.clsRTF wrapper.
Initialising
Ensuring update timer is stopped
Setting up base path
11:08:03 Could not find file "/home/peter/.config/Spacejock Software/yWriter7/POP3.xml" in clsFile:ReadUnicodeForced
11:08:03 Could not find file "/home/peter/.config/Spacejock Software/yWriter7/SMTP.xml" in clsFile:ReadUnicodeForced
11:08:03 Could not find file "/home/peter/.config/Spacejock Software/yWriter7/Accounts.xml" in clsFile:ReadUnicodeForced
Trying to create /home/peter/.config/Spacejock Software/yWriter7/
Setting log file name
Creating logfile
11:08:03
11:08:03
11:08:03
11:08:03
11:08:03 -----------------------------------
11:08:03
11:08:03 Log started: 20.01.2022
11:08:03 Logging to /home/peter/.config/Spacejock Software/yWriter7/Log.txt
11:08:03
11:08:03
11:08:03 RELEASE compile
11:08:03
11:08:03 Platform: LINUX
11:08:03 RELEASE compile
11:08:03 OS Description: Unix 5.11.0.43
11:08:03 Framework: Mono 6.12.0.122 (tarball Mon Feb 22 17:33:28 UTC 2021)
11:08:03 OS Architecture: X64
11:08:03 Process Architecture: X64
11:08:03 System version: v4.0.30319
11:08:03
11:08:03 Date format: dd.MM.yyyy
11:08:03 Date separator: .
11:08:03
11:08:03 Directory char: /
11:08:03
11:08:03 System Text Encoding: utf-8
11:08:03 System Codepage: 65001
11:08:03 Single byte system: False
11:08:03 Installed language: German (Germany)
11:08:03
11:08:03 True string: TRUE (True = -1)
11:08:03 False string: FALSE (False = 0)
11:08:03 -----------------------------------
11:08:03 yWriter7 7.1.2.9 startup
Logging system details
11:08:03 The method or operation is not implemented. in cSubs:SystemData
11:08:03 11:08:03, The method or operation is not implemented.

11:08:03
Creating splash screen
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
Showing splash
Deleting /home/peter/.config/Spacejock Software/yWriter7/7.1.2.9/
Docking controls
Setting up program icons
11:08:03 Installing spelling dictionaries
11:08:03 Could not find a part of the path '/home/peter/yWriter7/bin/Dict'. in clsFile:LocalFillFolders
11:08:03 Very first run of yWriter (no ini, no command line options. in frmMain:frmMain_Load
11:08:07 Settings file: /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini in frmMain:frmMain_Load
11:08:07 (not found) in frmMain:frmMain_Load
11:08:07 Loading settings from /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:08:07 /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini not found.
11:08:08 No translation files found in /home/peter/yWriter7/bin/Languages in clsLang:ScanLanguageFiles
11:08:08 One or more dictionaries found: spell check enabled in frmMain:LoadSpellingDictionaries
11:08:08 Dictionary folder: /home/peter/.config/Spacejock Software/yWriter7/Dict
11:08:09 Name and/or Serial empty
11:08:09 Name and/or Serial empty
11:08:09 Name and/or Serial empty
LoadProject
LoadProjV7
11:08:22 Locked project /home/peter/Dokumente/yWriter5 Sample/yW5 Sample Project.yw7
11:08:22 Extracting project from xml
11:08:22 Version 7 project
11:08:24 Project extracted
11:08:24 Backup to /home/peter/Dokumente/yWriter5 Sample/Autobackups/2022-01-20/yW5 Sample Project 2022-01-20 11.00 Full Backup.zip complete
11:08:24 Full backup succeeded
11:08:24 Alternate backup failed in frmMain:MakeAltBackup
11:08:32 2 action(s) in the main screen queue.
11:08:32 2 action(s) processed from the main screen queue. 0 action(s) remaining.
11:08:39 2 action(s) in the main screen queue.
11:08:42 Couldn't create editor for ScID: 1 in frmMain:EditScene
11:08:42 Could not load type of field 'LibSpacejockWin.SJSpeech.clsTalker:_Voice1' (0) due to: Could not load file or assembly 'System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. in frmMain:EditScene
11:08:42 2 action(s) processed from the main screen queue. 0 action(s) remaining.
11:09:26 Couldn't create editor for ScID: 1 in frmMain:EditScene
11:09:26 Could not load type of field 'LibSpacejockWin.SJSpeech.clsTalker:_Voice1' (0) due to: Could not load file or assembly 'System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. in frmMain:EditScene
11:09:51 Checking for update at http://www.spacejock.com/versions/yWriter7_current.txt
11:09:51 Checking for details at http://www.spacejock.com/versions/yWriter7_details.txt
11:09:51 Download package would be yWriter7Upd.exe
11:09:51 Download path would be /home/peter/.config/Spacejock Software/yWriter7/
11:09:53 Data retrieved From update server
11:09:53 Available version: 7.1.3.0
11:09:53 User has: 7.1.2.9
11:09:53 Version 7.1.3.0 Is available!
11:09:53 Attempting save to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:09:53 Settings saved to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:09:53 Saved to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:10:18 Attempting save to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:10:18 Settings saved to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:10:18 Saved to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:11:12 Couldn't create editor for ScID: 6 in frmMain:EditScene
11:11:12 Could not load type of field 'LibSpacejockWin.SJSpeech.clsTalker:_Voice1' (0) due to: Could not load file or assembly 'System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. in frmMain:EditScene
11:12:07 Saving settings
11:12:07 Previous project file copied to: /home/peter/Dokumente/yWriter5 Sample/yW5 Sample Project.V7.bak
11:12:07 Saving project to /home/peter/Dokumente/yWriter5 Sample/yW5 Sample Project.yw7
11:12:07 Packing project into XML data
11:12:07 Took 61,092 ms
11:12:07 Project save complete in SaveProject
11:12:07 Alternate backup failed in frmMain:MakeAltBackup
11:12:07 Unlocked project /home/peter/Dokumente/yWriter5 Sample/yW5 Sample Project.yw7
11:12:07 Attempting save to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:12:07 Settings saved to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:12:07 Saved to /home/peter/.config/Spacejock Software/yWriter7/yWriter7.ini
11:12:07 Closed down yWriter7

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Windows.Forms.XplatUIX11.DestroyOffscreenDrawable (System.Object offscreen_drawable) [0x00000] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.Windows.Forms.XplatUI.DestroyOffscreenDrawable (System.Object offscreen_drawable) [0x00000] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.Windows.Forms.Control+DoubleBuffer.Dispose () [0x00016] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.Windows.Forms.Control.DisposeBackBuffer () [0x00008] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.Windows.Forms.Control.Dispose (System.Boolean disposing) [0x00024] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.ComponentModel.Component.Dispose () [0x00000] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose()
  at System.Windows.Forms.ToolStripControlHost.Dispose (System.Boolean disposing) [0x00021] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.ComponentModel.Component.Finalize () [0x00000] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Windows.Forms.XplatUIX11.DestroyOffscreenDrawable (System.Object offscreen_drawable) [0x00000] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.Windows.Forms.XplatUI.DestroyOffscreenDrawable (System.Object offscreen_drawable) [0x00000] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.Windows.Forms.Control+DoubleBuffer.Dispose () [0x00016] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.Windows.Forms.Control.DisposeBackBuffer () [0x00008] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.Windows.Forms.Control.Dispose (System.Boolean disposing) [0x00024] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.ComponentModel.Component.Dispose () [0x00000] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0
  at (wrapper remoting-invoke-with-check) System.ComponentModel.Component.Dispose()
  at System.Windows.Forms.ToolStripControlHost.Dispose (System.Boolean disposing) [0x00021] in <6d635ac3dc1c4424ad385ded79f1e868>:0
  at System.ComponentModel.Component.Finalize () [0x00000] in <9c6e2cb7ddd8473fa420642ddcf7ce48>:0 

Peter T.

unread,
Jan 20, 2022, 6:55:25 AM1/20/22
to yWriter
In the meantime, I've looked a little deeper into yWriter 7 under Mono, and it doesn't even look that bad. I could not reproduce the crash experienced the first time I run yWriter 7.
  • Moving chapters and scenes is fiddly, but doable.
  • Scenes can be opened with "external editor", for me then automatically starts LibreOffice. Also the write back works.
  • Exporting doesn't seem to work at all, but I don't mind since I use my own Python file converters anyway.
In combination with my LibreOffice extension and Python tools, yWriter is quite usable under Mono, as long as it doesn't crash again.
  • What is annoying is that the status bar is black, so almost unreadable. You can see that on the screenshot. Is there anything that can be done?
  • The log suggests that the scene editor depends on the non-existent speech output. Maybe this can be caught in the program somehow? 
Cheers, 
Peter

Simon Haynes

unread,
Jan 20, 2022, 7:08:15 AM1/20/22
to ywr...@googlegroups.com
The speech engine is part of dotnet but not mono.

To get around the problem, I treat the speech engine as an object (var) in my code, instead of Speech, and only define it in Windows. However, there's still some remnant which is getting picked up in dotnet and is throwing an error.

The far bigger problem is that Winforms are broken under dotnet.  About seven years ago I reported the following bug, which still isn't fixed:

In Windows, you can set a variable called DialogResult anywhere in the form code. When the form exits, you can read this enum to see if it's Ok, Cancelled, etc.

In Mono, the second you set DialogResult to Cancelled, the form is closed and unloaded.

As you can imagine, this breaks nearly the entire application.

The only solution is to install dotnet 3.5/4.6.2/4.8  (yw5/6/7)  under wine and use the native libraries (which includes speech)



Peter T.

unread,
Jan 20, 2022, 7:21:35 AM1/20/22
to yWriter
Well, under Wine, yWriter 5 works very well (see my recent posting in the "Linux success stories" thread). The only thing is, yWriter takes an awfully long time to start. As mentioned before, that's why I wrote the Python file viewer that was introduced at thread start. 

Todd Carnes

unread,
Jan 20, 2022, 8:58:31 AM1/20/22
to ywr...@googlegroups.com
You have to add visual basic support separately. In Fedora the package
is called mono-basic. That's why I gave the command line "dnf install
mono mono-basic" in my post. I don't know what it's called on Ubuntu
systems, but a quick search in synaptic for the keyword "mono" should
bring up a list of mono and all it's add-ons.

Simon Haynes

unread,
Jan 20, 2022, 9:33:49 AM1/20/22
to ywr...@googlegroups.com
Until/if they fix Winforms under Mono yWriter isn't going to work.

I've waited years for a 'compile to Linux' option (using a version of mono that actually works).  Then they went down the Maui route, but that's not Linux either ... and it's been delayed, and on top of that it looks like it was designed to create smartphone apps with giant colourful buttons, not something like yWriter.


--
You received this message because you are subscribed to the Google Groups "yWriter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ywriter+u...@googlegroups.com.

Peter T.

unread,
Jan 26, 2022, 4:12:17 PM1/26/22
to yWriter
In the meantime I continued working on my file viewer and improved the user interface, which now also displays the number of chapters, scenes and words in a status bar.
The installation script creates a registry file under Windows that can be used to add a "View" entry to the yWriter 7 context menu.
Under Linux, this can be done very easily by hand (at least with the xfce file manager via custom actions):

screen01.png

Peter T.

unread,
Jan 27, 2022, 7:03:58 AM1/27/22
to yWriter
After finding a nice code example on Stack Overflow, my file viewer now has a "Rich Text" display. 

screen02.png
Reply all
Reply to author
Forward
0 new messages