/*_____________________________________________________________________________ |/ / Charmap add-on by David "Saturn" van Moolenbroek | Version 0.1, released 08-01-2004 -- support on #help.script/Quakenet | Use/modify however you want, but please keep my name in it. Thank you! | | Keywords: charmap, ASCII codes, dialogs, picture windows | | This add-on can display a character map, that is, a map of all the 256 | characters in a font. It does this by pre-generating the character map | using a picture window, and saving this to a .bmp file (see the $bitmap | alias in the code). It then uses a dialog to show the character map. The | pregeneration takes a while (about 250ms on my computer), but if you | display the same font more than once, without displaying another font in | between, it will only have to generate the font bitmap once. | | The charmap dialog works a bit differently from Windows' charmap.exe | program, only one click is enough to put a character in the editbox. | There are some minor issues with it, mostly due to the way mIRC works. | Remember, this add-on does not use any extensions like MDX... | | The script defines the following commands/identifiers: | | /charmap [font size] | | Displays a character map. You can optionally specify a font name and | size; the font name may contain spaces. If you do not specify a font | name and size, the script will use the font settings of the current | window. Note that if you specify a nonexisting font, mIRC will | automatically use a default one; there's no way for scripts to check | whether a font actually exists. | | Simple example | | /charmap fixedsys 9 \ _\_____________________________________________________________________________ */ alias -l bitmap return " $+ $scriptdir $+ charmap.bmp" alias -l discard alias -l bx return 10 alias -l by return 40 alias -l bw return $pic($bitmap).width alias -l bh return $pic($bitmap).height dialog -l charmap { title "Map of ASCII characters" size -1 -1 $calc($pic($bitmap).width + $bx * 2) $calc($pic($bitmap).height + $by + 57) option pixels notheme text "Font name:", 1, 10 10 60 18 edit "", 2, 75 8 150 20, read text "Font size:", 3, $calc($bx + $bw - 115) 10 60 18 edit "", 4, $calc($bx + $bw - 50) 8 50 20, read right icon 5, $bx $by $bw $bh, $bitmap text "", 6, $bx $calc($by + $bh + 7) $bw 18, center edit "", 7, $bx $calc($by + $bh + 27) $calc($bw - 180) 22, autohs button "C&opy", 8, $calc($bx + $bw - 170) $calc($by + $bh + 28) 80 20, ok focus button "&Close", 9, $calc($bx + $bw - 80) $calc($by + $bh + 28) 80 20, ok focus } alias -l chargen { if ($window(@charmap)) window -c @charmap var %i = 0, %w = 0, %h = 0 while (%i < 256) { if ($width($chr(%i),$2,$3) > %w) %w = $ifmatch if ($height($chr(%i),$2,$3) > %h) %h = $ifmatch inc %i } var %cw = $calc(%w + 5), %ch = $calc(%h + 5), %j = 0, %n = 0, %c window -dfhnopk0 @charmap 800 100 $calc(%cw * 32 + 1) $calc(%ch * 8 + 1) while (%j < 8) { %i = 0 while (%i < 32) { drawrect -n @charmap 1 0 $calc(%cw * %i) $calc(%ch * %j) $calc(%cw + 1) $calc(%ch + 1) if (%n != 32) { %c = $chr($iif($istok(0 2 3 15 22 31,%n,32),127,%n)) drawtext -n @charmap 1 $1 $3 $calc(3 + %cw * %i + (%w - $width(%c,$2,$3)) / 2) $& $calc(3 + %ch * %j + (%h - $height(%c,$2,$3)) / 2) %c } inc %i inc %n } inc %j } drawsave -b1 @charmap $bitmap window -c @charmap } alias -l charname { if ($findtok(0 1 2 3 9 10 13 15 22 30 31 32 160,$1,32)) $& return $gettok(null.ctcp.bold.color.tab.line feed.carriage return.normal. $& reverse. $+ $chr(127) $+ .underline.space.hard space,$ifmatch,46) return $chr($1) } alias -l current { var %x = $calc($mouse.x - $bx), %y = $calc($mouse.y - $by) var %w = $calc($bw - 1), %h = $calc($bh - 1) if ((%x >= %w) || (%y >= %h)) return -1 return $calc($int($calc(%x / (%w / 32))) + $int($calc(%y / (%h / 8))) * 32) } on *:DIALOG:charmap:sclick,dclick:5:{ var %c = $current if (%c == 32) set %charmap.space $true elseif (%c > 0) { did -ra charmap 7 $did(7) $+ $iif(%charmap.space,$chr(32)) $+ $chr(%c) unset %charmap.space } } on *:DIALOG:charmap:mouse:5:{ var %c = $current if (%c < 0) did -r charmap 6 else did -ra charmap 6 Ascii code %c $+ , hex 0x $+ $base(%c,10,16) ( $+ $charname(%c) $+ ) } on *:DIALOG:charmap:mouse:*:{ did -r charmap 6 } on *:DIALOG:charmap:sclick:8:{ clipboard $did(7) } on *:DIALOG:charmap:close:*:{ unset %charmap.space } alias charmap { if (($0 >= 2) && ($gettok($1-,-1,32) isnum)) { var %font = $deltok($1-,-1,32) var %size = $gettok($1-,-1,32) } else { var %font = $window($active).font var %size = $window($active).fontsize } if ((!$exists($bitmap)) || (%font != %charmap.font) || (%size != %charmap.size)) { discard $chargen($+(",%font,"),%font,%size) set %charmap.font %font set %charmap.size %size } dialog -m charmap charmap did -a charmap 2 %charmap.font did -a charmap 4 %charmap.size did -f charmap 7 unset %charmap.space }