[MonoDevelop] Some changes to ambiences

Mike Krüger mkrueger at novell.com
Thu Nov 27 01:26:57 EST 2008


Hi

I've extended the ambiences a bit. They're now more flexible, can fly,
cook coffe etc. 

It's now possible to specify an OutputSettings object that can do
further formatting. This class also is responsible for generating
markup. The default one generates pango markup, but it would be easy to
print any other markup using OutputSettings.
(The ambiences have done that itself in the past)

Therefore I changed the GetString to:

public abstract string GetString (IDomVisitable domVisitable, 
object settings);

Why setting is an object ? Because on the caller side nothing changes.
It's still valid to call:

----------------------------------------------------------------------
ambience.GetString (someMethod, OutputFlags.ClassBrowserEntries);
----------------------------------------------------------------------

This was my biggest concern: Keeping the ambiences easy to use and not
breaking any consuming code.

For output settings you can do something like:

-------------------------------------------------
OutputSettings settings = new OutputSettings
(OutputFlags.ClassBrowserEntries);

// change something in the settings

ambience.GetString (someMethod, settings);
-------------------------------------------------

The OutputSettings object contains some delegates that handle the
strings that are emitted by the underlying ambience. It has:

--------------------------------------------------
 public delegate string MarkupText (string text);

 public MarkupText EmitModifiers;
 public MarkupText EmitKeyword;

 public MarkupText Highlight;
 public MarkupText Markup;

--------------------------------------------------

EmitModifiers/Keywords is separated because it's possible to turn them
off seperately in the output flags. Highlight is used to highlight
names. Markup is used on any other text (like ":" or "<").

For changing the output string for special dom objects the PostProcess
can be used:
--------------------------------------------------
public ProcessString PostProcess;
public delegate void ProcessString (IDomVisitable domVisitable, ref
string outString);
--------------------------------------------------

This is useful for creating links for returntypes.

Example:
--------------------------------------------------
settings.PostProcess = 
delegate (IDomVisitable domVisitable, 
          ref string outString) {
  if (domVisitable is IReturnType)
   outString = "<span foreground=\"blue\"><u>" + 
               outString + 
               "</u></span>";
};
--------------------------------------------------
This example underlines return types and prints them blue.

Regards
Mike



More information about the Monodevelop-list mailing list