Menu

colorizers

Help
Mark Ng
2004-12-03
2013-04-26
  • Mark Ng

    Mark Ng - 2004-12-03

    How are the colorizers suppose to work ?
    I am trying to write a colorizer for perl, but the zinc
    sources doesn't make much sense to me.

     
    • Marc Kerbiquet

      Marc Kerbiquet - 2004-12-06

      To sum up, a colorizer is just an object with a method to colorize a line, given an array of chars and an initial state.

      The implementation is just a finite state automaton: an action is performed depending on the current state and the current char. The action is usually a combination of:
      - advance to next char
      - colorize the previous range of chars
      - switch to a different state.

      This model makes impossible to colorize some features of the perl language such as
      multiline strings using '<<XYZ'.

      If you want to implement a new colorizer, I could send you a detailed list of steps. It should not be too difficult by starting with copying a similar colorizer. The most difficult part is to define manually states and actions (this should normally be done by a regex compiler).

       
    • Mark Ng

      Mark Ng - 2005-01-06

      I just implemented a perl coloriser, it is still very alpha.
      The color is not always right around the edges and the color shifts as you move the cursor up and down as can be seen from the screenshot.

      Coloring things line by line does make heredocs and strings harder, but they are implemeted.  Also it reduces the effectiveness of regex's.

      Screenshot at:
      http://ng.freezope.org/code-browser-perl-hilite.png

      I'll sent you a diff when it gets more mature.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.