Giter Club home page Giter Club logo

synoptic's Introduction

Hi I'm Luke!

Profile views

What I'm building

I'm currently trying to build a compiler for a high level language.

My favourite languages:

Technologies I am familiar with:

Technologies I plan to learn in the future:


Curlpipe's github stats

synoptic's People

Contributors

curlpipe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

synoptic's Issues

Tokens, where to start and stop

Thanks for the library, it saves so much time getting started! I am using your library in a way you did not plan for, but allow.
I am using FLTK, and the backend is a buffer full of single characters.

fn example() {
    // test
}

Here is the FLTK version of the github highlighting above MOL

BBACCCCCCCAAAA
AAAAEEEEEEE
A

I currently use something like this:

let mut output:string = String::new();
//snip
for token in row {
    match token {
        Token::Start(kind) => {
            highlighting = true;
            match kind.as_str() {
                "keywords" => character = "B".to_string(),
                "comments" =>  character = "E".to_string(),
                //etc..
                _=> character = "A".to_string(),
            }
            output.push_str(character.as_str());// <-- here?
        }
        Token::Text(txt) => {
            let len = txt.chars().count();
            let ch = character.as_str();
            // `string.len()` == `text.len()`
            let string = ch.repeat(len);
            output.push_str(string.as_str());
        },
        Token::End(_) =>  {
            //output.push_str(character.as_str()); // <-- OR here?
            highlighting = false;
            character = "A".to_string();
        },
    }
}

Just not sure how to get it to be the correct length of the styling.
non-highlighted characters creep in, but I also end up with an incorrect len() if I do not push a some character to the output string.
image

That said, your library is quite intuitive and I really enjoy the thought you put into making it flexible!

Please change the code in the example.

In line 45 of your code example, it should be changed to Token::Start(kind) => match kind.as_str() {. The change is from match *kind to kind.as_str().

Built-in languages

Include pre-defined highlighters.

  • Rust
  • Python
  • Java
  • Javascript
  • C#
  • PHP
  • C
  • C++
  • R
  • Objective-C
  • Swift
  • TypeScript
  • CSS
  • HTML
  • MD
  • SQL
  • MATLAB
  • Perl
  • Assembly
  • Go
  • Ruby

Performance improvements

I could potentially look at a concurrent highlighting solution, where single line tokens, multiline tokens and bounded tokens are all calculated in parallel, hopefully that would speed up performance significantly.

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.