Friday, September 11, 2020

Finding a console Word Processor

I prefer to use terminal applications when possible, I'm just more comfortable in an XTerm. I'm not a purist about it, if the graphical application is better, then I'll use that instead. 

I recently looked around to see if there are any word processors that would work in a terminal. After trying all the available options, I decided that WordPerfect 6.2 for DOS from 1993 was exactly what I was looking for. This is probably a surprising choice, I'm not nostalgic for DOS software or a long-time holdout, I'm a new user in 2020.


It's remarkably powerful, I can use it over ssh, in tmux/screen, and there's still a community of knowledgeable users who will answer questions about advanced usage. 




I mentioned this in a discussion recently, and had a few questions from people who wanted to try it out, so here are my notes on how I set it up.

Before we begin, I know from experience that many people reading this will be shouting that I should be using a text editor. I can assure you, a text editor is not a word processor. If you're not convinced, please keep reading, I'll explain why below.


Configuring Dosemu

First, install dosemu2. Dosemu supports a terminal mode that translates VGA text mode operations into terminal operations using libslang. This makes software like WordPerfect look and act like a native ncurses application.

I used dosemu2 instead of dosemu, it's an updated and actively maintained fork of dosemu that doesn't rely on Virtual 8086 mode. This means it works on x86-64.

Run dosemu -term, and verify you get a C:\> prompt. If everything looks okay, type exitemu to return to Linux.

Installing WordPerfect

Create an installation directory in your C:\ drive like this:

$ cd ~/.dosemu/drive_c

$ mkdir install


Then copy the installation files, and run the installer:


$ dosemu -t

C:\ > cd install/install/wp62

C:\INSTALL\INSTALL\WP62 > install





I selected these options:


  • Standard Installation
  • Use Smart Prompting
  • No additional Graphic Drivers
  • No Sound Drivers
  • Yes Printer Drivers
    • Select Passthru PostScript

  • Install all Conversion Drivers
  • No Fax Files
  • Leave Serial Number Blank

Optional

There is an official patch available here that fixes a few minor bugs in the release build of WordPerfect 6.2. If you plan on using "classic" WordPerfect keybindings, then I don't think it's necessary.


If you plan to use CUA keybindings (Ctrl+C to copy, Ctrl+V to paste, Shift+Up to select, and so on), I would recommend using it. This is because it fixes some of those bindings. If you're not an old school WordPerfect user, then you will almost certainly be more comfortable with CUA bindings.


I used wine to run it.





Configuring Dosemu


I made a wrapper script like this:


#!/bin/bash

declare wpcmd='C:\COREL\WP62\WP.EXE /df /ds /ns /tx /sa'

if test $# -eq 1; then

    declare dir=$(dirname "${1}")

    declare file=$(basename "${1}")


    if cd "${dir}"; then

        wpcmd+=' G:\'

        wpcmd+="${file}"

    fi

fi


exec dosemu -term -E "${wpcmd}"

Call it wp and place it in your $PATH, now you can just run wp to start WordPerfect.

I also use this script to handle printer output, call it dosprint and also place it in your $PATH. It requires ghostscript to be installed.

#!/bin/bash

declare tmpfile=$(mktemp --tmpdir=${HOME}/Downloads --suffix=.pdf printjob.XXX)

if ps2pdfwr - ${tmpfile} > /dev/null; then

    xdg-open "${tmpfile}"

else

    rm -f ${tmpfile}

fi


Here is my ~/.dosemurc, if you want to use it as a template


# CPU shown to DOS, valid values:  "80[23456]86"

$_cpu = "80686"

$_cpu_emu = "vm86"

$_cpu_vm = "emulated"

$_cpu_vm_dpmi = "emulated"

$_ems = (32768)


# if possible use Pentium cycle counter for timing. Default: off

$_rdtsc = (on)


# 0 = all CPU power to DOSEMU; default = 1 = nicest, then higher:more CPU power

$_hogthreshold = (1)


# choose the time source for the RTC emulation.

$_timemode = "linux"


# Keyboard and mouse

$_layout = "uk"

$_rawkeyboard = "on"


$_mouse_internal = (off)


# Printer and parallel port settings

$_lpt1 = "dosprint"


# idle time in seconds before spooling out. Default: (20)

$_printer_timeout = (5)


# speaker: default: "emulated", or "native" (console only) or "" (off)

$_speaker = ""


# sound support

$_sound = (off)


# built-in Packet Driver. Default: on

$_pktdriver = (off)


Configuring WordPerfect


If you're a new WordPerfect user like me, you will probably prefer to use CUA bindings. 

  • Shift-F1 -> Keyboard Layout
    • Copy CUAWP52, call DOSEMU
    • Edit DOSEMU
    • If you installed the patch, Delete all the Pos/Sel Macros, they're not necessary.
    • Remap Ctrl+L to ItalicsKey Command (Ctrl+I is indistinguishable from Tab in a terminal, so you can't use that)
    • Select DOSEMU

There is mouse support in dosemu, but I don't use it, you can enable it if you prefer.


Word Processing vs Text Editing

The reason I want a word processor is to format and layout documents for printing. I believe this task is not suitable for a text editor.

Consider the following problem, I have a page of text I want to print in a proportional font (say, Helvetica 12pt). I need the document to fit on one page, and I'll edit it until it fits.

How would you do this with a text editor? Helvetica is a proportional font, which means calculating how each individual character will fit on the page is non-trivial. You'll have no feedback where lines wrap or the page breaks as you edit.

This is really easy in a word processor, it understands font geometry and physical page dimensions and gives you immediate realtime feedback as you type about where lines will wrap and pages break.




Security

I know someone will ask about security! 😂

Yes, I work in security, and yes I'm using software that hasn't been updated in 30 years.

I only use it to create new documents, but If you do need to open untrusted documents, then please don't use unsupported software!


Further Reading


If you're interested in reading more about WordPerfect DOS, there's a comprehensive site dedicated to it here, and an active community who answer questions about it here.

No comments: