Displaying text in a miniwindow

Posted by JJTim on Mon 22 Jul 2019 08:15 PM — 3 posts, 14,552 views.

Germany #0
Hi,

the Braille Reader plugin gave me the idea that I could also put otherimportant text from the MUD output in a separate miniwindow, to keep pretty repititive but important info like the prompt out of the general output (also reduces amount of text I need to read in the braille reader miniwindow). My idea was to create a window at the bottom right, which contains the prompt info I need. To achieve that, I created another plugin, and copied most of the Braille Reader window settings over (at least what I considered relevant for my miniwindow). Maybe I made a mistake, maybe I'm still missing a required part, or maybe the positioning of the miniwindow doesn't work this way -- either way, the text of the miniwindow is showing nowhere onscreen. Maybe you could assist me in finding a good position for the window, or tell me which mistake I made setting up the window?

Here's the plugin:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, July 22, 2019, 6:55  -->
<!-- MuClient version 5.05 -->

<!-- Plugin "Prompt_Miniwindow" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Prompt_Miniwindow"
   author="Tim Böttcher"
   id="3413610b552f5d5eadd25052"
   language="Lua"
   purpose="Show the MUD prompt in a miniwindow. Erase from output."
   date_written="2019-07-22 18:53:47"
   requires="5.05"
   version="1.0"
   >
  <description>
    <![CDATA[
      This plugin gets the prompt of the MUD and removes it from the output, instead displaying it in a miniwindow.
      This is useful for me as a deafblind user of the Braille Reader plugin; Maybe it's useful to others as well.
      To customize, 
        - change the value of the trigger's match attribute to match your MUD's prompt.
        - change the outputstring variable below at the start of the script.
        - insert all expected wildcards in the parameters of s:format (see below).
      For each wildcard, there must be a %s in the outputstring variable, or %q if you want the wildcard to appear in quotes.

      Example:
        match="^(\d+)\/(\d+) h (.*)$"
        outputstring = "%s/%s hp|%q"
        local text = outputstring:format (wildcards[1], wildcards[2], wildcards[3])
        Would match:
        60/300 h Not Poisoned
        And lead to the output:
        60/300 hp|"Not Poisoned"
    ]]>
  </description>
</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^[EXT=(.*) HNG=(\d+)] (\d+)\/(\d+)h, (\d+)\/(\d+)m (.*)$"
   omit_from_output="y"
   regexp="y"
   repeat="y"
   script="UpdatePromptMiniwindow"
   sequence="100"
  >
  </trigger>
</triggers>

<script>
  <![CDATA[
    outputstring = "EXT=%s HNG=%s %s/%sh %s/%sm %s" -- Change the format of the output here.
 
    -- Internal stuff.
    text_colour = ColourNameToRGB ("white")
    background_colour = ColourNameToRGB ("Black")
    win = "test_" .. GetPluginID ()
    font = "f"

    function UpdatePromptMiniwindow (name, line, wildcards)
      WindowRectOp(win, miniwin.rect_fill, 0, 0, 0, 0, background_colour, 0)
      local text = outputstring:format (wildcards[1], wildcards[2], wildcards[3], wildcards[4], wildcards[5], wildcards[6], wildcards[7])
      WindowText (win, font, text, 5, 5, 0, 0, text_colour, false)
    end -- function

    function OnPluginInstall ()
      TextRectangle(0, 0, 0, -50, 10, ColourNameToRGB("gray"), 2, ColourNameToRGB("silver"), miniwin.brush_solid)
      WindowCreate(win, 0, 0, 0, 0, miniwin.pos_bottom_right, 0, background_colour)
      WindowFont(win, font, "Courier", 14)
      width = WindowTextWidth(win, font, string.rep ("M", "80"))
      height = WindowFontInfo (win, font, 1)
      WindowCreate (win, 0, 0, width + 10, height + 10, miniwin.pos_bottom_right, 0, background_colour) 
      WindowShow (win,  true)
    end -- function 
  ]]>
</script>
</muclient>
Australia Forum Administrator #1
The window displayed OK when I tested it. However your trigger match is a bit wrong. You left out some backslashes before the square brackets. A square bracket without a backslash in front of it has a specific meaning in a regular expression. Try:


  match="^\[EXT=(.*) HNG=(\d+)\] (\d+)\/(\d+)h, (\d+)\/(\d+)m (.*)$"


It is also slightly different to the one in your other thread, for example you have here a comma after the "h" which you didn't have before, and a space at the end after the "m" which might not appear on a prompt line with nothing after the prompt. Try removing that space.
Amended on Mon 22 Jul 2019 10:17 PM by Nick Gammon
Germany #2
I do have backslashes in front of the [ and ] already?

The prompt I posted in the other thread was wrong, sorry. I had another trigger which altered the prompt output without me noticing. (Hence the trigger didn't match, because the actual prompt didn't look like that).

I also know that the trigger matches the prompt now, I tested it before. So if the miniwindow shows fine for you, and the prompt text appears within accordingly, then I guess JAWS doesn't perceive it in the bottom right position. Will have to play around with positions, then.

[EDIT] I tested with pos_bottom_left, and I can see the last part of the prompt now:
Original prompt:
[EXT=N,E,SE,S,W,NW HNG=100] 26/279h, 279/279m e -
Result I can see in miniwindow:
9m e -

Obviously, the Braille Reader window is overlapping the promt window now. I tried to move the prompt miniwindow to the right by replacing 0 with 100 in the WindowCreate calls, but that did not reveal more of the prompt.