shdqcdsn / counterclockwise

Automatically exported from code.google.com/p/counterclockwise
0 stars 0 forks source link

Refactor REPL log view styling so it can be compatible with external LineStyleListener #629

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This issue originates in the attempt to reuse the Eclipse Ansi Console plugin 
in order to provide support for displaying ANSI escape codes in the REPL log 
view  (ANSI codes are used in terminal application for coloring text).
An attempt to implement such support was successfully made as a CCW plugin. 
However the syntax coloring of past commands was lost, and the color contrast 
isn't perfect depending on the color theme.
Restoring syntax coloring is the primary goal of this issue. Ensuring better 
constrast may be resolved along the way, or may require a separate issue later 
on.
The reason why syntax coloring is lost is found in the StyledText widget API 
description: The following StyledText API is not supported if you have defined 
a LineStyleListener:
 - getStyleRangeAtOffset(int)
 - getStyleRanges()
 - replaceStyleRanges(int,int,StyleRange[])
 - setStyleRange(StyleRange)
 - setStyleRanges(StyleRange[])
The methods above are used to replicate clojure syntax coloring onto the log 
view of the REPL. When adding a LineStyleListener for enabling ANSI escape code 
support, these methods have no effect.
Probable resolution: refactor REPL styling into a LineStyleListener. The latter 
will either:
 - cache styles for each line, possibly because there might not be an easy way to compute these styles,
 - recompute the styles if possible, possibly making sure evaluation results are not syntax colored, so caching of which lines correspond to code may still be required.

References:
- CCW plugin script for adding ANSI escape code support in REPL view:
   https://gist.github.com/fmjrey/9889500
- It requires the  Eclipse ANSI Console:
   https://github.com/mihnita/ansi-econsole
- To see it in action you may want to install pretty 
(https://github.com/AvisoNovate/pretty) support in your lein profile.clj as 
explained in this blog post:
   http://z.caudate.me/give-your-clojure-workflow-more-flow/
- Here is a screenshot showing a pretty-printed stack trace:
   https://cloud.githubusercontent.com/assets/489016/2577576/835361f2-b981-11e3-8f30-2fcf79160ad5.jpg
- StyledText API:
   http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fcustom%2FStyledText.html

Original issue reported on code.google.com by fmjrey on 5 Apr 2014 at 12:42

GoogleCodeExporter commented 9 years ago
Original discussion:
https://groups.google.com/d/msg/clojuredev-users/d3rXWdWTJAs/pBwq30BB6LgJ
Discussion on ANSI Console issues list:
https://github.com/mihnita/ansi-econsole/issues/6

Original comment by fmjrey on 5 Apr 2014 at 2:43

GoogleCodeExporter commented 9 years ago
Made the necessary changes in this pull request:
https://github.com/laurentpetit/ccw/pull/30

Original comment by fmjrey on 12 Apr 2014 at 7:37

GoogleCodeExporter commented 9 years ago
Fine, thanks for the hard work!

As soon as I've finalized leiningen problems I'll study your patch, seems quite 
exciting already!

Original comment by laurent....@gmail.com on 17 Apr 2014 at 8:25

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 22 May 2014 at 8:20

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 26 Jun 2014 at 8:19

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 10 Jul 2014 at 8:10

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 25 Sep 2014 at 9:28