Menu

Syntax highlighting for console.

NppExec
q3dm3
2016-12-19
2016-12-26
  • q3dm3

    q3dm3 - 2016-12-19

    Hi Vitaliy !
    How are you, how is your eyes ?
    I was (I'm still) over 3 months without internet(this is my first contact), so don't know what was happening recently in NP++, but I'm posting right now what I have prepared during offline time. I'm still using NP++ v6.9.2 and Python 3.5.2. Check lines below please.

    .,A,.
    Is possible to code feature for NppExec console, which would copycat NP++'s Style configurator's settings and apply it for console with current file opened ? (every type of file has different syntax ..)
    Console would dig into NP++'s settings, suck it out, use same.
    And synchronize on the fly(instantly) text size of NP++ with text size of console.
    It wouldn't be good, if console would have it's own syntax highlighting (for every filetype), because it would look different from NP++'s. Size obvious too. Coding would become confusing.
    Thank you

    .,B,.
    And this is maybe a bug.
    Please try this code(python3):

    import tkinter as tk
    dialog = tk.Tk()
    dialog.title('Simple Form')
    dialog.mainloop()

    It worked, but not this line from console:
    dir(tk)

    Nothing happend. Console was not frozen, but it was in stage of long waiting for response. Probably some infinite loop of waiting or I don't know.
    I tried same thing in original Python's IDLE and it worked immediatelly.
    No matter how old pc, it was just few lines: http://i.imgur.com/wrqOIUa.png
    Thank you

    .,C,.
    And an issue:
    I copied one unicode character from some text and tried how works python builtins ord() and chr().
    Screen from npp:
    http://i.imgur.com/MLZ2hmf.png

    and screen from python's idle:
    http://i.imgur.com/TcePaXG.png

    Can you explain please ?
    Thank you

    .,D,.
    And is possible to code feature, which would monitor all words in currently opened file and use them for auto-completing ? Similar like in NP++, but numbers excluded.
    But if user would switch to other file, console would switch the word database too.
    Thank you

    .,E,.
    And what about fixing that console's copying external text formatting into itself during copy-paste ?
    Thank you

    .,F,.
    And just minor thingy. That console is laggy in general. I can see it well on my old pc. When I'm holding Enter key for new line-ing, it can't display it in time, but just at the end (stopped pressing).
    http://i.imgur.com/udRCbFn.png
    Thank you

    Link to my topic, let me know what do you think:
    https://notepad-plus-plus.org/community/topic/12801/notepad-v7-2-2-released/26

     
  • DV

    DV - 2016-12-21

    A.
    Not possible. Notepad++ uses Scintilla for editing and syntax highlight, whereas NppExec uses RichEdit.

    B.
    For me it works.
    Probably you did not start Python with "-u" argument, e.g. "python -u -i".

    C.
    It's about character encoding, it depends on system locale and, moreover, can be different in different applications.
    For me, python's console also prints '?'.
    Try to experiment with settings under Plugins -> NppExec -> Console Output...
    To have 100% correct bahavior, execute "env_set PYTHONIOENCODING=utf-8" right before running python.exe. Also set UTF8/UTF8 in the Plugins -> NppExec -> Console Output... You'll see that ord() returns different number in that case, and passing that number to chr() types a correct character.
    The UTF8/UTF8 setting will most likely be incompatible with other console applications, so it will be a good idea to surround the execution of python.exe with this:

    env_set PYTHONIOENCODING=utf-8 // tell Python to use UTF-8 I/O encoding
    npe_console o2 i2 // tell NppExec to use UTF-8 I/O encoding
    python -u -i // run Python
    npe_console o1 i1 // tell NppExec to use OEM (DOS) I/O encoding
    

    D.
    Not possible, too complicated.

    E.
    Will be done.

    F.
    I'll check it on my old netbook.

     
  • q3dm3

    q3dm3 - 2016-12-21

    B, C
    You know I'm using NP++ and NppExec 3 months old (32 bit everything), it was last time I had internet.
    So I have now settings like this (four text config modules for console):
    [img]http://i.imgur.com/YW8EmMQ.png[/img]

    [img]http://i.imgur.com/PxMD9p6.png[/img]

    [img]http://i.imgur.com/cUl51ss.png[/img]

    [img]http://i.imgur.com/0vQ0NyD.png[/img]

    So, first do you suggest me to update to newest NP++ version and update also your console (exact link please ?) and then change those four text modules to which exactly text ? (pastebin me exactly text to avoid misunderstandings)

    Have patience with me please, I don't want destroy my setup after long months of useable state.

    Thank you very much :)

     

    Last edit: q3dm3 2016-12-21
  • DV

    DV - 2016-12-22

    Notepad++ may be updated - just to use the latest verion of Notepad++. It does not affect the behavior of NppExec, though.
    NppExec itself has not been updated.

    As for changes in NppExec's script, the common practice is to:
    1. Try to change something;
    2. See if it works OK for you;
    3. Keep the changes if everything is OK (for you) or revert the changes if it's not.

    You've mentioned 4 NppExec's scripts. In each of those scripts, there is a line "python [python arguments]" where by "[python arguments]" I mean either "-i -u" or "-u" or "" (no arguments).
    E.g. in case of "python -u" the "[python arguments]" part is "-u", and in case of "python -i -u" the "[python arguments]" part is "-i -u".
    OK?

    Now, returning to your NppExec's scripts, each line in the form of

    python [python arguments]
    

    needs to be replaced with the following lines:

    env_set PYTHONIOENCODING=utf-8 // tell Python to use UTF-8 I/O encoding
    npe_console o2 i2 // tell NppExec to use UTF-8 I/O encoding
    python [python arguments] // run Python
    npe_console o1 i1 // tell NppExec to use OEM (DOS) I/O encoding
    

    Clear?

    Then, if something will work not as you want, you can always revert the changes by either commenting out or by deleting the newly added lines. E.g.:

    // env_set PYTHONIOENCODING=utf-8 // tell Python to use UTF-8 I/O encoding
    // npe_console o2 i2 // tell NppExec to use UTF-8 I/O encoding
    python [python arguments] // run Python
    // npe_console o1 i1 // tell NppExec to use OEM (DOS) I/O encoding
    
     
  • q3dm3

    q3dm3 - 2016-12-22

    Is it correct ?

    But now I have more rubbish text with it, which I dont want:

    I used to have just READY line and file path line.
    How remove those lines please ?

    Thank you

    update:
    one example worked, but some other didn't:

    and i see this:

     

    Last edit: q3dm3 2016-12-23
  • DV

    DV - 2016-12-24

    Yes, you've added correct commands. To exclude the additional lines from the Console, two more commands need to be added:

    npp_console - // Console output off
    env_set PYTHONIOENCODING=utf-8 // tell Python to use UTF-8 I/O encoding
    npp_console + // Console output on
    npe_console o2 i2 -- // tell NppExec to use UTF-8 I/O encoding, silent
    python [python arguments] // run Python
    npe_console o1 i1 -- // tell NppExec to use OEM (DOS) I/O encoding, silent
    
     
  • q3dm3

    q3dm3 - 2016-12-25

    it works now, but you didn't mention, that you also added this: --
    to end of two lines: npe_console o2 i2, npe_console o1 i1

    if i write: chr(1011), i stil get [], instead what i get in idle: 'ϳ'

    thank you

     

    Last edit: q3dm3 2016-12-25
  • DV

    DV - 2016-12-25

    I think it's correct because the character code 1011 (hex 0x03F3) is not a simple latin 'j'. This symbol looks like a part of Greek alphabet - and, correspondingly, requires a font that supports these symbols. As far as I can see, for example, a "Courier New" font supports them and, for example, "Lucida Console" does not.

     
  • q3dm3

    q3dm3 - 2016-12-26

    If you like my new ideas in topic I linked in first post, please support me there. It needs to be done.
    Many ty

    I have just tried this:

    NPP_SAVE
    set local @exit_cmd_silent = nppexec:proc_signal ctrlbreak
    cd "$(CURRENT_DIRECTORY)"
    //npp_console -
    env_set PYTHONIOENCODING=utf-8
    //npp_console +
    npe_console o2 i2 --
    python -u -i "$(FILE_NAME)"
    npe_console o1 i1 --
    

    I commented out lines: npp_console -, npp_console +, which you told me to add. But result is still as I want without those lines ! What if desired changes made just double hyphens in lines:
    npe_console o2 i2 --, npe_console o1 i1 --

    Please explain
    Ty

     

    Last edit: q3dm3 2016-12-26

Log in to post a comment.