Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Displaying text in a miniwindow

Displaying text in a miniwindow

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by JJTim   Germany  (21 posts)  Bio
Date Mon 22 Jul 2019 08:15 PM (UTC)
Message
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>
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 22 Jul 2019 10:16 PM (UTC)

Amended on Mon 22 Jul 2019 10:17 PM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by JJTim   Germany  (21 posts)  Bio
Date Reply #2 on Tue 23 Jul 2019 07:15 AM (UTC)

Amended on Tue 23 Jul 2019 08:03 AM (UTC) by JJTim

Message
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.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,302 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.