Git Product home page Git Product logo

Comments (13)

magiblot avatar magiblot commented on August 18, 2024 2

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.

from turbo.

magiblot avatar magiblot commented on August 18, 2024 2

Commit f368936 adds syntax highlighting for Ruby. What do you think?

Screenshot_20201024_021805

from turbo.

chernish2 avatar chernish2 commented on August 18, 2024 1

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

from turbo.

magiblot avatar magiblot commented on August 18, 2024 1

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

from turbo.

mingodad avatar mingodad commented on August 18, 2024 1

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

from turbo.

magiblot avatar magiblot commented on August 18, 2024

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.

from turbo.

magiblot avatar magiblot commented on August 18, 2024

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.

from turbo.

chernish2 avatar chernish2 commented on August 18, 2024

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?

from turbo.

chernish2 avatar chernish2 commented on August 18, 2024

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!

from turbo.

chernish2 avatar chernish2 commented on August 18, 2024

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

from turbo.

magiblot avatar magiblot commented on August 18, 2024

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

from turbo.

chernish2 avatar chernish2 commented on August 18, 2024

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

from turbo.

magiblot avatar magiblot commented on August 18, 2024

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

from turbo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.