#2234 Linear display of long symbols and strings

closed
nobody
Lisp Core (471)
2
2011-09-02
2011-07-25
No

In linear display expressions with long symbols or strings are not formated as expected. This is an example for 2d-display and for linear display. The option variable linel is set to 10:

(%i1) display2d:true$

(%i2) a+b+c+ddddddd+eeeeeee+ffffffffffffff;
(%o2) fff\ fffffffff\ ff + eeee\ eee + ddd\ dddd + c
+ b + a

Again for linear display. The spaces in the output are replaced by points to show the format in this posting:

(%i3) display2d:false$

(%i4) a+b+c+ddddddd+eeeeeee+ffffffffffffff;

(%o4) ffffffffffffff
.......+eeeeeee
.......+ddddddd
.......+c
.......+b
.......+a

In linear display there are two problems. First, long symbols and strings are not broken up. This is a problem in the function mprint. Second, in linear display the available space is not used fully. This problem is caused in the function linear-display. This function prints out the output label directly. Therefore the format of the output label is not under control of the function mprint.

The second problem is solved by providing a function msize-label, which does the formating of the output label under control of the functions msize and mprint. This is an example with a new msize-label function:

(%i1) a+b+c+ddddddd+eeeeeee+ffffffffffffff;
(%o1)
ffffffffffffff
+eeeeeee
+ddddddd
+c+b+a

Still, the first problem is present. Long symbols are not broken up.

Dieter Kaiser

Discussion

  • Dieter Kaiser

    Dieter Kaiser - 2011-08-14

    In linear display we have no functions for formating mlable- and mtext-expressions. The formating is done in the function linear-displa. Therefore, the output of such expressions in linear-displa is not under the control of the function mprint which is responsible for the output of a formated expression. In 2d-display this problem does not exist.

    The following two functions implement the formating of mlable- and mtext-expression for linear display:

    ;;; ----------------------------------------------------------------------------

    ;; Formating a mlable expression

    (defprop mlable msize-mlabel grind)

    (defun msize-mlabel (x l r)
    (declare (special *display-labels-p*))
    (cond (*display-labels-p*
    (setq l (msize (cadr x) (list #\( ) (list #\) #\ ) nil nil)
    r (msize (caddr x) nil r 'mparen 'mparen))
    (cons (+ (car l) (car r)) (cons l (cons r nil))))
    (t (msize (caddr x) l r 'mparen 'mparen))))

    ;;; ----------------------------------------------------------------------------

    ;; Formating a mtext expression

    (defprop mtext msize-mtext grind)

    (defun msize-mtext (x l r)
    (setq x (cdr x))
    (if (null x)
    (msz nil l r)
    (do ((nl) (w 0))
    ((null (cdr x))
    (setq nl (cons (if (atom (car x))
    (msz (makestring (car x)) l r)
    (msize (car x) l r lop rop))
    nl))
    (cons (+ w (caar nl)) (nreverse nl)))
    (setq nl (cons (if (atom (car x))
    (msz (makestring (car x)) l r)
    (msize (car x) l nil lop rop))
    nl)
    w (+ w (caar nl))
    x (cdr x)
    l nil))))

    ;;; ----------------------------------------------------------------------------

    With this definitions the function linear-displa reduces to the following code:

    (defun linear-displa (form)
    (fresh-line *standard-output*)
    (mgrind form *standard-output*)
    (terpri))

    Furthermore, the global variable fortranp is no longer necessary and can be cut out completely. It is set in linear-displa to signal the function msize-atom that a mtext-expression has to be formated.

    Dieter Kaiser

     
  • Dieter Kaiser

    Dieter Kaiser - 2011-09-02
    • status: open --> closed
     
  • Dieter Kaiser

    Dieter Kaiser - 2011-09-02

    An implementation of a function msize-mlable and msize-text has been committed to grind.lisp revision 03.09.2011.
    Closing this bug report as fixed.
    Dieter Kaiser

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks