grob: Render expressions in expression mode

This ensures that we get the right multiplication operators.

Fixes: #1148

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
Christophe de Dinechin 2024-08-31 23:15:09 +02:00
parent 83d85d91aa
commit c6068d1c37
4 changed files with 9 additions and 5 deletions

View file

@ -2083,6 +2083,7 @@ GRAPH_BODY(expression)
size_t depth = rt.depth();
bool ok = true;
bool funcall = o->type() == ID_funcall;
save<bool> sexpr(g.expression, true);
// First push all things so that we have the outermost operators first
for (object_p obj : *expr)

View file

@ -253,14 +253,16 @@ struct grapher
font_id f = settings::EDITOR,
grob::pattern fg = grob::pattern::black,
grob::pattern bg = grob::pattern::white,
bool stack = false)
bool stack = false,
bool expr = false)
: maxw(w),
maxh(h),
voffset(0),
font(f),
foreground(fg),
background(bg),
stack(stack)
stack(stack),
expression(expr)
{}
grapher(const grapher &other) = default;
@ -287,6 +289,7 @@ struct grapher
grob::pattern foreground;
grob::pattern background;
bool stack;
bool expression;
};
#endif // GROB_H

View file

@ -997,7 +997,7 @@ GRAPH_BODY(object)
// The default for rendering is to render the text using default font
// ----------------------------------------------------------------------------
{
renderer r(nullptr, ~0U, g.stack, true);
renderer r(nullptr, ~0U, g.stack, true, g.expression);
using pixsize = blitter::size;
size_t sz = o->render(r);
gcutf8 txt = r.text();

View file

@ -42,10 +42,10 @@ struct renderer
// ----------------------------------------------------------------------------
{
renderer(char *buf = nullptr, size_t len = ~0U,
bool stk = false, bool ml = false)
bool stk = false, bool ml = false, bool expr = false)
: target(buf), length(len), written(0), saving(), tabs(0), column(0),
edit(!stk && buf == nullptr),
expr(false), stk(stk), mlstk(ml), txt(false),
expr(expr), stk(stk), mlstk(ml), txt(false),
needSpace(false), gotSpace(false),
needCR(false), gotCR(false) {}
renderer(bool equation, bool edit = false, bool stk = false, bool ml = false)