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 ➜ Suggestions ➜ color cut & paste?

color cut & paste?

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


Posted by Wnohgb-washu   USA  (5 posts)  Bio
Date Mon 13 May 2002 03:57 PM (UTC)
Message
I know this is likely not going to happen, but wouldn't it really be nifty if when you cut colored text, it would copy the colors as well?

This would only work on Ansi colors, of course, and I think incompatabilities with MXP would be an issue.

I do a fair amount of ascii art, and coloring it can be a pain.

It would be really nifty if I could find some editor that let color text with ansi, then dump the text it using user-editable codes to represent the colors (so that a moo user like myself could have [bold][red]<text>[normal] dumped for easy pasting.

I could even live happily if there was some way of turning HTML log files into ansi.

Again, I doubt any of these suggestions are possible, but I provide them here in the hope that it might actually be possible. Here's hoping (but not expecting)
Top

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #1 on Mon 13 May 2002 06:07 PM (UTC)

Amended on Mon 13 May 2002 06:22 PM (UTC) by Shadowfyr

Message
Hmm. Well html to ansi is probably not a problem. You are right though that MXP is not totally compatible, but then strangely enough I have yet to see a mud that uses MXP that uses the extended color capabilities rather than doing something really stupid like underlining all the names of NPCs and players, which gives me eye strain. lol However.. converting may be relatively easy, you would need something like qbasic (which came with old versions of dos), then a program to run on it like>


open "c:\logfile.log" for input as #1
open "c:\ansifile.ans" for output as #2
do

  input #1,A$
  b$ = ""
  for x = 1 to len(a$)
    if mid$(a$,x,1) = "<" then
      if lcase$(mid$(a$,x,12)) = "<font color=" then
        x = x + 11 '1 less than length, so that next statement doesn't eat the following character. 
        tmp$ = ""
        for y = x to len(a$)
          if mid$(a$,y,1) = ">" then
            x = x + y - 1
            exit for
          end if
          if mid$(a$,y,1) <> chr$(34) then
             tmp$ = tmp$ + mid$(a$,y,1)
          end if
        next y
        if y = len(a$) then
          x = len(a$)
          exit 
        end if
        gosuob 1000 'Match to color
      end if
      if lcase$(mid$(a$,x,6)) = "<nbsp>" then
        b$ = b$ + " "
        x = x + 5
      end if
      if lcase$(mid$(a$,x,7)) = "<\font> then
        x = x + 6
    else
      b$ = b$ + mid$(a$,x,1)
    end if 
  next
loop until eof(1)
close
system
1000 'Lets see if we can match these to an ansi color!
  select case tmp$
    case "000000"
      b$ = b$ + chr$(27) + "[0m"
    case ... 'Additional cases statement for each color.
    case else
      'If it isn't a standard color.
      'This part would be tricky and involves figuring out
      'what the closest ansi color wold be to correctly
      'match. It may be easier to split the tmp$ into red,
      ' green and blue then go from there in such cases.
  end select
return

The above would catch color changes and non=breaking spaces, which I assume are the most likely things to show up in any html log. I believe MUSHclient's docs either in help or on the website have a list of the hex values you can expect for the standard ansi colors. You can probably peek into a log to find any that are not shown, since I think the docs only show the high-color ones. :p So ansi 15 is shown as FFFFFF, but ansi 7 (dark white/grey) is not shown at all.

I also haven't tested the above at all so it may not work 100% right. ;) Assuming I got it right though, you would simply add additional 'case "######"' statements for each known color and the appropriate ansi string and run it with 'qbasic /run myprog.bas'.

On another note.. Maybe the option of selecting the text in the windows and right-clicking to get an option for 'copy with color' would be useful, since it would allow this, but preserve the existing behavior for normal copying.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 14 May 2002 01:36 AM (UTC)
Message
Quote:

I know this is likely not going to happen, but wouldn't it really be nifty if when you cut colored text, it would copy the colors as well?


The new script functions in 3.20 are designed to allow you to do that, with a bit of scripting. :)

The general idea is to:


  1. Select some text in the output window
  2. Type some alias you would make, eg. "colour_copy"
  3. The alias calls a script. The script ...

    • Finds the start and end of the selection using world.GetSelectionStartLine and world.GetSelectionEndLine
    • For each of those lines, uses world.GetLineInfo to find how many style runs are in each line.
    • For each style run, use world.GetStyleInfo to find the text (contents) of that style, and also the foreground and background colour
    • Assuming you haven't used MXP or trigger colouring, the colours should match ones in your ansi colour list
    • Use world.GetNormalColour and world.GetBoldColour to find which colour correspond to each RGB colour
    • Generate appropriately formatted output (eg. ANSI codes, HTML, MUD colour codes, or whatever)


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


11,640 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.