Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Custom 'help' script

XithXith Member Posts: 2,602 @@ - Legendary Achaean
Does anybody have one yet that they use for documentation of their own distributed systems?
If not, I'm building one to use with a few systems I'll be distributing over time. While I hope to charge a bit for the systems, I hope people can make use of my 'xhelp' system. So with that in mind, collaborators are welcome. Unless someone has already done this better than I have.

Took an embarrassing amount of time to get it doing what I want. The main issue is wrapping of course. Still have an issue there...


The border symbols and 3 colors are easily customizable. Red names are accessible help files, the white text under it is supposed to be a list of functions/features that could ideally be red when they have their own value in the table. The problem is that <colortags> are counted in a string's length and it keeps messing up the wrapping if I color it before wrapping instead of after.

So does anyone know of a decent help script or want to help with mine?
I like my steak like I like my Magic cards: mythic rare.

Comments

  • SenaSena Member Posts: 3,957 @@ - Legendary Achaean
    I'm not sure of the details and can't help much with actually writing the script, but my ideas for solving the problem are:
    Make your own length function which strips out the colour tags before getting the length.
    Colour the text after wrapping, if possible.
    If the lines are static instead of being created dynamically, explicitly store the length of each line yourself.
  • KeneanungKeneanung Member Posts: 618 ✭✭✭✭ - Eminent
    This goes with Sena's first suggestion:

    local function mylength(str)
      local clearString = str:gsub("(<(%a*):?(%a*)>)", function(complete, fg, bg)
        if (fg == "reset" and bg == "") or
          (color_table[fg] and bg == "") or
          (fg == "" and color_table[bg]) or
          (color_table[fg] and color_table[bg]) then
          return ""
        end
        return complete
      end)
      return clearString:len()
    end


    I am not sure about the completeness of all combinations but it should show the general way I'd do it. Note that this relies on you using color names and cecho (and not hecho/decho etc)
    Xith
  • XithXith Member Posts: 2,602 @@ - Legendary Achaean
    edited January 2015





    I love you forever @Keneanung‌
    EDIT: and @Sena‌
    I like my steak like I like my Magic cards: mythic rare.
    Valaria
  • XithXith Member Posts: 2,602 @@ - Legendary Achaean
    Putting the final touches on the functionality. Once it's running smoothly with my own packages I'll make it publicly available for free. Hopefully anyone will use it to include documentation with their own scripts.


    I like my steak like I like my Magic cards: mythic rare.
    Klendathu
Sign In to Comment.