Calysto/scilab_kernel

The output contains white spaces for each line of code

ezalorpro opened this issue · 4 comments

hello, basically as the title says, the output contains blank spaces for each line of code even with semicolons:

image

Scilab kernel v0.9.10
Metakernel v0.24.2
Python v3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)]
Python path: C:\Program Files (x86)\Python37-32\python.exe

Connecting to Scilab...
Scilab connection established
Scilab version "6.0.2.1550134035"
scilab-6.0.2

Hi @ezalorpro, this is a known issue but I'm not sure how to solve it.

@blink1073 Well in that case , i took a look to the code of the kernel, and since i dont know anything about it, i took the naive approach of pre process the execute code and clean it from '\n' and comments lines. I dont think thist approach is robust enought in the long term, more testing is requiered, but so far it is not bad. Maybe making use of regular expression whould be a beter choice, but i dont know literaly nothing about regex so . . .

def do_execute_direct(self, code, silent=False):
        
        # Extra code for better output
        temp = ''
        code = code.lstrip().rstrip('\n')
        NumLines = code.count('\n')

        for i, line in enumerate(code.split('\n')):
            line = line.lstrip().rstrip().split('//')
            if line[0] is not '':
                if line[0].rstrip()[-1] is not ';' and i != NumLines:
                    temp += line[0].lstrip().rstrip() + '\n'
                elif line[0].rstrip()[-1] is ';' or i == NumLines:
                    temp += line[0].lstrip().rstrip()

        code = temp
        .
        .
        .

EjemploKernelScilab

cheers.

the extra white lines could be suppressed by setting the display mode to 0, means you could add mode(0) at the beginning of the worksheet.

thanks.

rgds,
Chin Luh

@ezalorpro: Works fine. Thanks for sharing.

Except if you have an URL in mprintf() or disp() commands. The "//" makes trouble. But not a big deal.