# [texworks] Early thoughts

Herbert Schulz herbs at wideopenwest.com
Fri Sep 19 00:16:20 CEST 2008

On Sep 18, 2008, at 11:41 AM, Jérome Laurens wrote:

>>> ...
>>> (5) As well as command completion, I'd like automatic trigger stuff.
>>> E.g., typing \begin{ on an otherwise empty line would immediately
>>> insert an \end{ on the next line and then fill in both environment
>>> delimiters at the same time as you typed the name of the
>>> environment.
>>> Editing one of them would edit the other, simultaneously.
>>
>> Yes, that'd be slick.
>
> possible and sexy but rather hard to implement.
> Instead, "\begin{" can popup a tiny panel with nothing but a text
> field where the user enters the name of the environment.
> Pressing enter will close this window and complete the \begin
> command with the proper template.
> To have a better idea, go to address book, select one card and edit
> one field, you'll get the idea.
>
> I think this is related to Herb's suggestion about command completion.
>
> Basically, here is the problem.
> The user enters a combination of keystrokes and the text editors
> answers by editing the text.
> What Will and Herb are refering to is automated editing tasks.
> In general, the editor inserts templates with placeholders, and the
> user has to navigate from one placeholder to the next to fill in the
> proper values.
> Xcode does this rather efficiently.
> There is another way of doing those things: we can popup a small
> form with a very small number of controls where the user will fill
> in fields, check boxes and whatever.
> In such a form there can be explanations. From the developer point
> of view, this is very interesting because it separates the different
> From the user POV, this is very interesting because it clearly
> identifies an editing unit.
>
> In some situations, the standard way of doing things is good, but in
> others, using a form is definitely the way to go.
> If we come back to the "\begin{" problem, the ultimate UI is a form
> where the user can see a list of available environments in a combo
> box,
> and once he has chosen the environment, he can choose the
> appropriate options related to this environment, if any.
>
> By the way, the user should have a menu of the most frequently used
> actions where he could find an item that reads "Insert environment"
> and
> acts the same way as "\begin{" by calling the same code of course.
> That is called UI mutability, in order to adapt the app to the user
> needs.

Howdy,

Just to note that in TeXShop you can write

\begin{xxx}

and then pressing ESC the corresponding

\end{xxx}

is entered on the next line with the cursor left after the end of the
closing } of the \begin line. In practice I would put a \b at the
start of the line, press ESC to get a completion to \begin{, write the
environment name and the closing } and press ESC again. Not
necessarily the cleanest but it works. If I had to do that more than a
couple of times I'd add the environment to the completion list with an
abbreviation.

I'd love to see an implementation of the form method. I'm not much of
a programmer. I also would like to be able to jump to invisible place
holders rather than use the bullet but have the same excuse. Also,
jumping using the Tab key rather than something else would be nice but
I worry about scoping problems. Finally, it may be fairly easy to
retain indentation by having the software replace #RET# in the
completion file by newline+indentation of line insertion starts'
rather than just newline' but I don't think I've thought that through
or know ow to do that elegantly.

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)