Libreoffice Math (Formula Editor) should have bracket matching

Bug #1698572 reported by Norbert
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
LibreOffice
Confirmed
Wishlist

Bug Description

Steps to reproduce:
1. Open LibreOffice Math
2. Type some formula with brackets
3. Forget to enter closing bracket.
4. Get "??" in formula preview.

Expected results:
* LibreOffice Math has bracket matching.

Actual results:
* LibreOffice Math does not have bracket matching.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: libreoffice-math 1:5.1.6~rc2-0ubuntu1~xenial2
ProcVersionSignature: Ubuntu 4.4.0-79.100-generic 4.4.67
Uname: Linux 4.4.0-79-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.6
Architecture: amd64
CurrentDesktop: MATE
Date: Sat Jun 17 22:12:21 2017
InstallationDate: Installed on 2014-02-07 (1225 days ago)
InstallationMedia: Ubuntu 12.04.4 LTS "Precise Pangolin" - Release amd64 (20140204)
SourcePackage: libreoffice
UpgradeStatus: Upgraded to xenial on 2017-04-15 (62 days ago)

Revision history for this message
In , Reisi007 (reisi007) wrote :

Created attachment 53686
How syntax highlighting should work

Hi there!

It would be great to have syntax highlighting in Math...
Everything from importance is in the .odt file.

Florian

Revision history for this message
In , Giuliano Lotta (giuliano69) wrote :

Complety right.
Even Gedit use sintax hilight.

It is very hard when you have a lot og {{{((( to understand where you are in the formula and when to close a braket/graph

Could help a lot in formula writing

Revision history for this message
In , Reisi007 (reisi007) wrote :

Thank you. BTW; changed version.. and Status to NEW

Revision history for this message
In , Vanz-x (vanz-x) wrote :

I'm taking a look the bugs formula editor, to classify then and after try to solve them. I downloaded the file attachment and there are some germany comments on it. Is something relevant?

Revision history for this message
In , Vanz-x (vanz-x) wrote :

(In reply to comment #3)
> I'm taking a look the bugs formula editor, to classify then and after try to
> solve them. I downloaded the file attachment and there are some germany
> comments on it. Is something relevant?

Well, I used google translate. So, sorry disturb you.

Revision history for this message
In , Vanz-x (vanz-x) wrote :

I'll start to work in this bug. Do you have some code pointers?
I was taking a look on EditEngine and EditView sources. I think we have to implement this on these classes, right?

Revision history for this message
In , Reisi007 (reisi007) wrote :

No idea (regarding codepointer) Anyone?
Feel free to ask @ libreoffice-dev IRC channel @ freenode

Revision history for this message
In , Norbert (nrbrtx) wrote :

Syntax highlighting and bracket matching will be very useful.

Revision history for this message
Norbert (nrbrtx) wrote :
Revision history for this message
In , Norbert (nrbrtx) wrote :

Bug exists in

Version: 5.4.1.2
Build ID: 1:5.4.1~rc2-0ubuntu0.16.04.1~lo0
CPU threads: 4; OS: Linux 4.4; UI render: default; VCL: gtk2;
Locale: en-US (en_US.UTF-8); Calc: group

Ubuntu 16.04 LTS with PPA.

Norbert (nrbrtx)
tags: added: bionix
tags: added: bionic
removed: bionix
Revision history for this message
In , Norbert (nrbrtx) wrote :

On Ubuntu i

Changed in df-libreoffice:
importance: Unknown → Wishlist
status: Unknown → Confirmed
Revision history for this message
Olivier Tilloy (osomon) wrote :

Closing the bug against the source package, as it's not a packaging bug, but a missing feature upstream.

Changed in libreoffice (Ubuntu):
status: New → Invalid
no longer affects: libreoffice (Ubuntu)
Revision history for this message
In , kompilainenn (79045-79045) wrote :

Would be cool to have highlight of operands/functions in Formula editor

Revision history for this message
In , Xiscofauli (xiscofauli) wrote :

Changing priority back to 'medium' since the number of duplicates is lower than 5

Revision history for this message
In , Dante19031999 (dante19031999) wrote :

*** Bug 48671 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Csernt (csernt) wrote :

I have an idea how to solve the problem simply and with much greater effect: allow users to use theys favorite EXTERNAL text editor to edit formula, i.e. parameter "External math text editor path" in settings needed. It it empty - LibreOffice Math runs, else the LibreOffice (or LibreOffice Math without GUI) run this actions:

- create temp file XXXXX.eqn on trying to fornmula edit/create
- run external text editor with this file as parameter
- read file after editor closing and update formula object as it LibreOffice Math does

It's AUTOMATICALY enables features on user side:

- pair brackets highlighting
- functions highlighting
- more simple editing (change variable name with multicaret editing or vim commands, e.t.c.)
- snippets (not only for math constructions, may be used to natural greek symbols writing - [a]+[Tab] -> α instead of %alpha - more simple reading)
- macroses to text editing in some special cases

It seems to be a great effect for easy implementation - don't you think so?

Revision history for this message
In , Vstuart-foote (vstuart-foote) wrote :

(In reply to Sergey from comment #13)
> I have an idea how to solve the problem simply and with much greater effect:
> allow users to use theys favorite EXTERNAL text editor to edit formula, i.e.
> parameter "External math text editor path" in settings needed. It it empty -
> LibreOffice Math runs, else the LibreOffice (or LibreOffice Math without
> GUI) run this actions:
>
> - create temp file XXXXX.eqn on trying to fornmula edit/create
> - run external text editor with this file as parameter
> - read file after editor closing and update formula object as it LibreOffice
> Math does
>
> It's AUTOMATICALY enables features on user side:
>
> - pair brackets highlighting
> - functions highlighting
> - more simple editing (change variable name with multicaret editing or vim
> commands, e.t.c.)
> - snippets (not only for math constructions, may be used to natural greek
> symbols writing - [a]+[Tab] -> α instead of %alpha - more simple reading)
> - macroses to text editing in some special cases
>
> It seems to be a great effect for easy implementation - don't you think so?

This would require the "external" editor to prepare formula in viable MathML that could be parsed back into ODF. Sorry, but I don't see how this would provide anything that can't already be accomplished adding logic to node composition in the current sm formula editor module with more direct changes.

Revision history for this message
In , Csernt (csernt) wrote :

Thanks, V Stuart Foote!

Of cause, I mean only "eqn" text editing by external editor (no MathML and other parts of formula object). For example LO Math may check settings on start and run external editor, than LO Math generates all this MathML as in normal mode - the only difference - it takes text from file, not from textbox.

But! This feature is already particulary realized in iMath plugin. Problem that it's don't open formula objects without "%%ii" text inside.

Also: iMath and CompPad can update formula after text changing. May be they do it with LibreOffice Math. So, may be more simple way exists to edit formula object?
---------------------------------------------------------
Link to iMath:
https://sourceforge.net/projects/ooo-imath/
Discussion:
https://sourceforge.net/p/ooo-imath/feature-requests/75/
To see how it works:
1. Install https://sourceforge.net/projects/ooo-imath/files/Beta%20versions/iMath-2.3.1/iMath-2.3.1~beta2.oxt/download
1. Open Service -> Parameters... -> LibreOffice Writer -> iMath global settings
2. Write path it field "Editing" (if problems - try to use path without spaces, else you may try to write just editor file name and than change %PATH%)
3. Create formula with "Insert" button on panel, write a=10+20 for example
4. Press right mouse button on formula and select Edit iFormula -> External Editor
---------------------------------------------------------
Link to ComPad (not maintainted now)
https://sourceforge.net/projects/comppad/

Revision history for this message
In , Rafael Lima (rafael-palma-lima) wrote :

Created attachment 169284
Math Highlighting Comments

Dante, I built your patch and I have a few suggestions to make (see the attached ODG file "Math Highlighting Comments").

1) Keywords could be marked as bold to make it clear for the user that a format command is being used. This is important because sometimes the user thinks the word will be treated as text when it is in fact a command. For a complete list of commands, refer to the Math Guide (https://wiki.documentfoundation.org/images/a/a2/MG70-MathGuide.pdf).

2) The double quotes for strings could be formatted together with the string itself (see the example in the attached file)

The following three comments are not part of this patch, but could be considered in a future enhancement you'll submit.

3) I liked the color combination you chose. However, in the future there could be options for Math under Tools > LibreOffice > Application Colors for the user to change the colors if h/she desires (as currently there is for other LO components).

4) Currently in the Formula Editor, the line breaks at a weird position, near the middle of the editor. It could be better to use all the available screen space.

5) There could be way to increase the size of the font in the Formula Editor (I mean the font used for the markup language). The current size is a bit small. I think the easiest way to implement this is to use the same configuration that's applied for the Basic IDE (which is the font set under Tools > Options > Fonts in the "Font Settings for HTML, Basic and SQL Sources".

I'm available to test/comment future versions of this patch or new patches you submit to the Math component.

Revision history for this message
In , Dante19031999 (dante19031999) wrote :

Created attachment 169287
Math Highlighting Comments

Answer to Rafael Lima

Revision history for this message
In , Dante19031999 (dante19031999) wrote :

(In reply to Rafael Lima from comment #16)

The answer may disappoint you.

> 1) Keywords could be marked as bold to make it clear for the user that a
> format command is being used. This is important because sometimes the user
> thinks the word will be treated as text when it is in fact a command. For a
> complete list of commands, refer to the Math Guide
> (https://wiki.documentfoundation.org/images/a/a2/MG70-MathGuide.pdf).

This is gonna require a bit more work behind the scenes.
There are some changes that should be done before using more the system to replace.
It is related with matml compatibility and operator priority list.
When ready will implement it.

> 2) The double quotes for strings could be formatted together with the string
> itself (see the example in the attached file)

Done.

> The following three comments are not part of this patch, but could be
> considered in a future enhancement you'll submit.
>
> 3) I liked the color combination you chose. However, in the future there
> could be options for Math under Tools > LibreOffice > Application Colors for
> the user to change the colors if h/she desires (as currently there is for
> other LO components).

I did make sure the colors where "easy" to switch.
They are declared as a list instead of numerically inserted in the code.
However changing that may require themes and other complicated stuff I don't knwon how to use.

> 4) Currently in the Formula Editor, the line breaks at a weird position,
> near the middle of the editor. It could be better to use all the available
> screen space.

No clue about how to change it.
The number of columns seems fixed whatever you do.
I guess it's related with paper size.
However don't know.
https://opengrok.libreoffice.org/xref/core/include/editeng/editeng.hxx?r=88c0e46e&mo=3646&fi=140#140
https://opengrok.libreoffice.org/xref/core/include/editeng/editview.hxx?r=c83166ce#135

> 5) There could be way to increase the size of the font in the Formula Editor
> (I mean the font used for the markup language). The current size is a bit
> small. I think the easiest way to implement this is to use the same
> configuration that's applied for the Basic IDE (which is the font set under
> Tools > Options > Fonts in the "Font Settings for HTML, Basic and SQL
> Sources".

Already done. Check the attached document.

> I'm available to test/comment future versions of this patch or new patches
> you submit to the Math component.

Patchset 24, available in a couple of hours has the change about the text.

Revision history for this message
In , Rafael Lima (rafael-palma-lima) wrote :

Created attachment 169343
Highlighting Numeric Values

Dante! I ran Patchset 27 and all is working. At least from my tests, I couldn't produce any wrong behavior.

There was just one thing that occurred to me (see the new attached file). Maybe you could apply a highlight color to numeric values, as it is currently done in Basic. Also, you could use the same shades of Blue and Green that are used by Basic.

I am not saying that you should use the same color constants as Basic does, but rather innitialy assign the same colors used by Basic to the color constants you created.

However, these are just suggestions. You could try them out and see if it's a good idea.

Revision history for this message
In , Dante19031999 (dante19031999) wrote :

(In reply to Rafael Lima from comment #19)
> Created attachment 169343 [details]
> Highlighting Numeric Values

> There was just one thing that occurred to me (see the new attached file).
> Maybe you could apply a highlight color to numeric values, as it is
> currently done in Basic. Also, you could use the same shades of Blue and
> Green that are used by Basic.

I applied the same color to numbers and hexadecimal values as well (right now command not available, but machinery already implemented, available in 15 days), but not RGB hexadecimal values ( color#RRGGBB (available from 7.1) ) or font sizes or other numeric parameters.

> I am not saying that you should use the same color constants as Basic does,
> but rather initially assign the same colors used by Basic to the color
> constants you created.

About basic, I did never used it, but I don't think it uses the same kind of tokens. I looked some screenshots and I'm still not sure about the token types (blue and green). The numbers are in a red variant as in your screenshot in basic, but more pale. I'm using non bright CSS3 colors for it and I don't really believe we need a parallelism with another software or module.

Maybe, I'll be able to add an entry on expert configuration for changing colors.
I'll check it out. But building the UI for normal users is way too complicated.

> However, these are just suggestions. You could try them out and see if it's
> a good idea.

It also hit me to put comments in gray, but I haven't the internal machinery done yet.

Changed in df-libreoffice:
status: Confirmed → In Progress
Norbert (nrbrtx)
tags: added: focal hirsute impish jammy
removed: xenial
Revision history for this message
In , Xiscofauli (xiscofauli) wrote :

Dear Dante,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assign it back to yourself if you're still working on this.

Changed in df-libreoffice:
status: In Progress → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.