turbo icon indicating copy to clipboard operation
turbo copied to clipboard

[Feature request]

Open chernish2 opened this issue 3 years ago • 13 comments

  • It would be nice to have a "Help" menu on the top right, like almost every old TV software has. Just for the feel of it. It could contain only one item like "About". Would be super-cool!
  • Also it would be nice to have a switch between 25 lines and 43/50 lines (like ALT+F9 in NC or VC for example).

turbo

chernish2 avatar Oct 21 '20 15:10 chernish2

Hi Alexey! Thanks for your suggestions. Unfortunately, I don't have much time to work on new features.

It would be nice to have a "Help" menu on the top right, like almost every old TV software has. Just for the feel of it. It could contain only one item like "About". Would be super-cool!

This is very simple to do. Why don't you try it yourself? The menu bar entries are defined in the function TMenuBar *TurboApp::initMenuBar(TRect r) in src/app.cc. The tvdemo sample application in the main Turbo Vision repository has an example of an "About..." dialog.

Also it would be nice to have a switch between 25 lines and 43/50 lines (like ALT+F9 in NC or VC for example).

While I understand this may be nostalgic, I really don't see the point of it. You are on Linux, right? Then the most comfortable thing you can do is resize the terminal window with the mouse. The same happens on modern Windows. The 25 vs 43/50 lines choice was a limitation of the hardware and the operating system of the era. Modern terminal applications don't work like that. I can't instruct the terminal to use a 8x8 font, either.

magiblot avatar Oct 21 '20 15:10 magiblot

What I said about the "About" dialog was not a joke. If you have some free time, writing a little bit of C++ can be a good entertainment. I encourage you to try it.

magiblot avatar Oct 21 '20 20:10 magiblot

Ok, thanks. Probably it would be better idea to try to enable Ruby highlighting then. Because I really need it. Can you provide some insights?

chernish2 avatar Oct 22 '20 10:10 chernish2

This is a bit more difficult because it implies understanding internal details of Scintilla. But basically:

  • In scintilla/include/SciLexer.h there are the following defintions:

    1. The lexer, which is the program that parses Ruby text.
    #define SCLEX_RUBY 22
    
    1. The styles, which have to be associated with a color.
    #define SCE_RB_DEFAULT 0
    #define SCE_RB_ERROR 1
    #define SCE_RB_COMMENTLINE 2
    #define SCE_RB_POD 3
    #define SCE_RB_NUMBER 4
    #define SCE_RB_WORD 5
    #define SCE_RB_STRING 6
    #define SCE_RB_CHARACTER 7
    #define SCE_RB_CLASSNAME 8
    #define SCE_RB_DEFNAME 9
    #define SCE_RB_OPERATOR 10
    #define SCE_RB_IDENTIFIER 11
    #define SCE_RB_REGEX 12
    #define SCE_RB_GLOBAL 13
    #define SCE_RB_SYMBOL 14
    #define SCE_RB_MODULE_NAME 15
    #define SCE_RB_INSTANCE_VAR 16
    #define SCE_RB_CLASS_VAR 17
    #define SCE_RB_BACKTICKS 18
    #define SCE_RB_DATASECTION 19
    #define SCE_RB_HERE_DELIM 20
    #define SCE_RB_HERE_Q 21
    #define SCE_RB_HERE_QQ 22
    #define SCE_RB_HERE_QX 23
    #define SCE_RB_STRING_Q 24
    #define SCE_RB_STRING_QQ 25
    #define SCE_RB_STRING_QX 26
    #define SCE_RB_STRING_QR 27
    #define SCE_RB_STRING_QW 28
    #define SCE_RB_WORD_DEMOTED 29
    #define SCE_RB_STDIN 30
    #define SCE_RB_STDOUT 31
    #define SCE_RB_STDERR 40
    #define SCE_RB_UPPER_BOUND 41
    
  • In src/styles.h there is a list of languages:

enum Language : unsigned char {
    langNone,
    // ...
    langRuby, // <-- this is the one you want
    // ...
};
  • In src/editstates.cc there is a list that associates file extensions with a language:
static const const_unordered_map<std::string_view, Language> ext2lang = {
    {".js",         langJavaScript},
    // ...
    {".rb",         langRuby}, // <-- already in the list, no need to touch anything
    // ...
};
  • In src/styles.cc there is a list that associates languages with a lexer and styling information, to which you'll have to add Ruby:
static const const_unordered_map<Language, LexerInfo> lexerStyles = {
    {langCPP, {SCLEX_CPP, stylesC, keywordsC, propertiesC}},
    {langMakefile, {SCLEX_MAKEFILE, stylesMake, nullptr, nullptr}},
    {langAsm, {SCLEX_ASM, stylesAsm, nullptr, nullptr}},
    {langJavaScript, {SCLEX_CPP, stylesC, keywordsJavaScript, propertiesC}},
    {langRust, {SCLEX_RUST, stylesRust, keywordsRust, nullptr}},
    {langPython, {SCLEX_PYTHON, stylesPython, keywordsPython, propertiesPython}},
    {langBash, {SCLEX_BASH, stylesBash, keywordsBash, nullptr}},
};

Each entry in this list has the following fields:

  1. The language identifier.
  2. A struct with more fields:
    1. The lexer.
    2. A 'styles' list.
    3. A 'keywords' list.
    4. A 'lexer properties' list. These are settings offered by the lexer. You can ignore this for now and set it to nullptr.

So please look at the 'styles' and 'keywords' lists that are already defined for the other languages and figure out how to make one for Ruby. Please notice that the last element in the 'styles' list has to be {(uchar) -1, {}},, and the last element in the keywords list has to be {(uchar) -1, nullptr},.

To understand what every SCE_RB_ constant means, you can took at the lexer's source code in scintilla/lexers/LexRuby.cxx.

magiblot avatar Oct 22 '20 11:10 magiblot

Thank you for clarification! I checked the project and found it a little bit hard for me. So I'm hoping that you will have some time in the future to add Ruby (I tried SciTe and it understand Ruby syntax). Thank you!

chernish2 avatar Oct 22 '20 13:10 chernish2

Commit https://github.com/magiblot/turbo/commit/f368936fc3f78117b1f0845ca7d35fc40e9db3d3 adds syntax highlighting for Ruby. What do you think?

Screenshot_20201024_021805

magiblot avatar Oct 24 '20 00:10 magiblot

Following my own instruction, git clone etc, then it fails to build:

[ 96%] Linking CXX static library libscintilla.a [ 96%] Built target scintilla Scanning dependencies of target turbo [ 97%] Building CXX object CMakeFiles/turbo.dir/cmake_pch.hxx.gch In file included from /home/chernish2/soft/turbo/CMakeFiles/turbo.dir/cmake_pch.hxx:5:0, from :0: /home/chernish2/soft/turbo/include/ScintillaHeaders.h:48:10: fatal error: filesystem: No such file or directory #include ^~~~~~~~~~~~ compilation terminated. CMakeFiles/turbo.dir/build.make:82: recipe for target 'CMakeFiles/turbo.dir/cmake_pch.hxx.gch' failed make[2]: *** [CMakeFiles/turbo.dir/cmake_pch.hxx.gch] Error 1 CMakeFiles/Makefile2:123: recipe for target 'CMakeFiles/turbo.dir/all' failed make[1]: *** [CMakeFiles/turbo.dir/all] Error 2 Makefile:102: recipe for target 'all' failed make: *** [all] Error 2

chernish2 avatar Oct 24 '20 07:10 chernish2

The filesystem header again... Like I said in the other thread, can you try the following command and then compile again?

rm CMakeCache.txt && CXX=g++-8 cmake .

You may also want to change the default compiler version. The following pages might help you:

https://stackoverflow.com/questions/7832892/how-to-change-the-default-gcc-compiler-in-ubuntu

https://askubuntu.com/questions/26498/how-to-choose-the-default-gcc-and-g-version

magiblot avatar Oct 24 '20 10:10 magiblot

My bad, forgot about that. Works AMAZING! Thank you!

chernish2 avatar Oct 24 '20 10:10 chernish2

Is it possible to add file history? Would be very convenient.

chernish2 avatar Oct 24 '20 10:10 chernish2

Yes, I know. I don't think I will be able to add it as quickly as the Ruby syntax. It will take longer.

magiblot avatar Oct 24 '20 10:10 magiblot

Is it possible to add file history?

In the meantime, you can take advantage of the "File > Suspend" feature (if you were not doing so already).

Instead of doing this:

  • Open files in Turbo > Close > Do things in the shell > Open Turbo and files again.

You can do this:

  • Open files in Turbo > Suspend > Do things in the shell > Run fg > Continue using Turbo

magiblot avatar Oct 25 '20 13:10 magiblot

Another nice to have would be a filebrowser on one side like geanny, vscode, codeblocks, netbeans, ...

mingodad avatar Nov 06 '20 16:11 mingodad