[ZeroBrane Studio] Re: Change the tooltip formatting via interpreter? How to distribute interpreter & api?

  • From: Paul K <paul@xxxxxxxxxxxxx>
  • To: "zerobrane@xxxxxxxxxxxxx" <zerobrane@xxxxxxxxxxxxx>
  • Date: Tue, 28 Oct 2014 18:30:05 -0700

Hi Jan,

> But 1. and all those events and Scintilla functions require in-depth
> Scintilla and wxWidgets knowledge, two things I do not have. Honestly, I
> would not know where to start. On what editor to call connect? What should

You are of course correct; my apologies. Here is a crude prototype
that may work (it's a diff against referencepanel.lua):

diff --git a/referencepanel.lua b/referencepanel.lua
index 546674e..f0ba401 100644
--- a/referencepanel.lua
+++ b/referencepanel.lua
@@ -22,6 +22,11 @@ return {
           :MinSize(w,-1):BestSize(w,-1):FloatingSize(w,h)
       end)

+    
SetupKeywords(e,"lua",nil,ide.config.styles,ide.font.oNormal,ide.font.oItalic)
+    StylesApplyToEditor(ide.config.styles,e,ide.font.oNormal,ide.font.oItalic)
+    -- this allows the markup to be not only comments
+    for i = 0, 16 do e.spec.iscomment[i] = true end
+
     local font = ide:GetOutput():GetFont()
     e:SetFont(font)
     e:StyleSetFont(wxstc.wxSTC_STYLE_DEFAULT, font)
@@ -34,6 +39,10 @@ return {
     -- disable dragging to the panel
     e:Connect(wxstc.wxEVT_STC_DO_DROP, function(event)
event:SetDragResult(wx.wxDragNone) end)

+    e:Connect(wxstc.wxEVT_STC_UPDATEUI, function(event)
+        MarkupStyle(e,0,e:GetLineCount()) -- style the entire document
+      end)
+
     local menu =
ide:GetMenuBar():GetMenu(ide:GetMenuBar():FindMenu(TR("&View")))
     menu:InsertCheckItem(4, id, TR("Reference Window")..KSC(id))
     menu:Connect(id, wx.wxEVT_COMMAND_MENU_SELECTED, function (event)
@@ -57,7 +66,7 @@ return {

     -- update the reference text
     refeditor:SetReadOnly(false)
-    refeditor:SetText(tip)
+    refeditor:SetText("something **abc** _def_\n"..tip)
     refeditor:SetReadOnly(true)

     local pane = ide:GetUIManager():GetPane(refpanel)

SetupKeywords and StylesApplyToEditor setup the "lua" specification
and the same styles as used in the "main" editor; "iscomment" table
keeps track of where markup is recognized (as MarkupStyle only
recognizes markup in comments), the next fragment adds UPDATEUI event
handler, and SetText just adds fake **abc** (bold) and _def_ (italic)
text to every tooltip.

Note that this is only a prototype as I'd prefer to wrap those calls
into some public API, but it should be simple enough to demonstrate
the results.

This covers items 1 and 2 on the list. If you need a different markup
syntax, you can copy the function and make changes to the syntax.

Paul.

Other related posts: