Difference between revisions of "Konwert"

From NetHackWiki
Jump to navigation Jump to search
m
(Completed bulk of article. Could probably still use a few tweaks.)
Line 1: Line 1:
It is possible to configure [[custom map symbols]] to arbitrary UTF8 characters using <code>konwert</code>. All that is required is to set each of the BOULDER, DUNGEON, TRAPS, EFFECTS, OBJECTS, and WARNINGS options to ASCII codes that are definitely not going to be used for any purpose other than drawing the map, then remap those values to the UTF8 characters you want.
+
It is possible to configure [[custom map symbols]] to arbitrary UTF8 characters using <code>konwert</code>. All that is required is to set each of the DUNGEON, TRAPS, EFFECTS, OBJECTS, and WARNINGS options to ASCII codes that are definitely not going to be used for any purpose other than drawing the map, then remap those values to the UTF8 characters you want.
  
 
== Configuring Nethack ==
 
== Configuring Nethack ==
 
Turning on the eight_bit_tty option gives you access to character codes 128-255 which aren't otherwise used, so it's easiest just to set the various symbols to use those character codes, starting at 128:
 
Turning on the eight_bit_tty option gives you access to character codes 128-255 which aren't otherwise used, so it's easiest just to set the various symbols to use those character codes, starting at 128:
  
  BOULDER = 128
+
  DUNGEON= 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 \
  DUNGEON = 129 130 131...
+
          144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 \
-- TODO: Finish this.
+
          160 161 162 163 164 165 166 167 168
 +
TRAPS=                                        169 170 171 172 173 174 175 \
 +
          176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
 +
EFFECTS=                                                              191 \
 +
          192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 \
 +
          208 209 210 211 212 213 214 215 216 217 218 219
 +
OBJECTS=                                                  220 221 222 223 \
 +
          224 225 226 227 228 229 230 231 232 233 234 235 236
 +
  WARNINGS=                                                     237 238 239 \
 +
          240 241 242
  
 
== Configuring konwert ==
 
== Configuring konwert ==
<code>konwert</code> filters are just executable shell scripts, and it will look for them in your ~/.konwert/filters/ directory. The cp437-utf8 filter is a good starting-point, copy it into your personal filters directory from /usr/share/konwert/filters/cp437-UTF8. Edit it and remove the <code>-e</code> argument and the text that follows. Rename it 'nethack'.
+
<code>konwert</code> filters are just executable shell scripts, and it will look for them in your ~/.konwert/filters/ directory. The cp437-UTF8 filter is a good starting-point, copy it into your personal filters directory from /usr/share/konwert/filters/cp437-UTF8. Edit it and remove the <code>-e</code> argument and the text that follows. Rename it 'nethack'.
This filter looks for the character set conversion table ~/.konwert/aux/charsets/nethack - that is where you'll map the hexadecimal values of the character codes to actual UTF8 characters. You'll want to start with something like this:
+
This filter looks for the character set conversion table ~/.konwert/aux/charsets/nethack - that is where you'll map the hexadecimal values of the character codes to actual UTF8 characters. Here's the file I'm using at the moment (I really should get around to specifying characters for those traps):
  
# BOULDER
 
\x80 '
 
 
  # DUNGEON
 
  # DUNGEON
  \x81 \x20
+
\x80 \x2F
  \x82 |
+
  \x81 &#9475;
-- TODO: Finish this.
+
\x82 &#9473;
 +
\x83 &#9487;
 +
\x84 &#9491;
 +
\x85 &#9495;
 +
\x86 &#9499;
 +
\x87 &#9547;
 +
\x88 &#9531;
 +
\x89 &#9523;
 +
\x8A &#9515;
 +
\x8B &#9507;
 +
\x8C &#9634;
 +
\x8D &#9633;
 +
\x8E &#9633;
 +
\x8F &#9635;
 +
\x90 &#9635;
 +
\x91 &#9637;
 +
\x92 &#9827;
 +
\x93 &#183;
 +
\x94 &#9617;
 +
\x95 &#9618;
 +
\x96 &#9003;
 +
\x97 &#8998;
 +
\x98 &#8970;
 +
\x99 &#8969;
 +
\x9A &#10015;
 +
\x9B &#8745;
 +
\x9C &#9796;
 +
\x9D &#9697;
 +
\x9E &#8752;
 +
\x9F &#8858;
 +
\xA0 &#9731;
 +
\xA1 &#9832;
 +
\xA2 &#9550;
 +
\xA3 &#9548;
 +
\xA4 &#9578;
 +
\xA5 &#9579;
 +
\xA6 &#8779;
 +
\xA7 &#9729;
 +
\xA8 &#8780;
 +
# TRAPS
 +
\xA9 ^
 +
\xAA ^
 +
\xAB ^
 +
\xAC ^
 +
\xAD ^
 +
\xAE ^
 +
\xAF ^
 +
\xB0 ^
 +
\xB1 ^
 +
\xB2 ^
 +
\xB3 ^
 +
\xB4 ^
 +
\xB5 ^
 +
\xB6 ^
 +
\xB7 ^
 +
\xB8 ^
 +
\xB9 ^
 +
\xBA "
 +
\xBB ^
 +
\xBC ^
 +
\xBD ^
 +
\xBE ^
 +
# EFFECTS
 +
\xBF &#9474;
 +
\xC0 &#9472;
 +
\xC1 &#9586;
 +
\xC2 &#9585;
 +
\xC3 &#9762;
 +
\xC4 &#9889;
 +
\xC5 &#10095;
 +
\xC6 &#10094;
 +
\xC7 &#9716;
 +
\xC8 &#9717;
 +
\xC9 &#9718;
 +
\xCA &#9719;
 +
\xCB &#9581;
 +
\xCC &#9472;
 +
\xCD &#9582;
 +
\xCE &#9474;
 +
\xCF &#9474;
 +
\xD0 &#9584;
 +
\xD1 &#9472;
 +
\xD2 &#9583;
 +
\xD3 &#9586;
 +
\xD4 &#9474;
 +
\xD5 &#9585;
 +
\xD6 &#9472;
 +
\xD7 &#9587;
 +
\xD8 &#9472;
 +
\xD9 &#9585;
 +
\xDA &#9474;
 +
\xDB &#9586;
 +
# OBJECTS
 +
\xDC &#9797;
 +
\xDD &#9876;
 +
\xDE &#9678;
 +
\xDF &#9702;
 +
\xE0 &#9791;
 +
\xE1 &#9773;
 +
  \xE2 &#9803;
 +
\xE3 &#9905;
 +
\xE4 &#9802;
 +
\xE5 &#10064;
 +
\xE6 /
 +
\xE7 $
 +
\xE8 &#9830;
 +
\xE9 &#9679;
 +
\xEA &#9864;
 +
\xEB &#9783;
 +
\xEC &#10022;
 +
# WARNINGS
 +
\xED &#185;
 +
\xEE &#178;
 +
\xEF &#179;
 +
\xF0 &#8308;
 +
\xF1 &#8309;
 +
\xF2 &#8310;
  
 
You can then place whatever UTF8 characters you want into the second column (the \x20 is there to represent a space character that wouldn't otherwise be noticed by <code>konwert</code>).
 
You can then place whatever UTF8 characters you want into the second column (the \x20 is there to represent a space character that wouldn't otherwise be noticed by <code>konwert</code>).

Revision as of 11:50, 17 July 2008

It is possible to configure custom map symbols to arbitrary UTF8 characters using konwert. All that is required is to set each of the DUNGEON, TRAPS, EFFECTS, OBJECTS, and WARNINGS options to ASCII codes that are definitely not going to be used for any purpose other than drawing the map, then remap those values to the UTF8 characters you want.

Configuring Nethack

Turning on the eight_bit_tty option gives you access to character codes 128-255 which aren't otherwise used, so it's easiest just to set the various symbols to use those character codes, starting at 128:

DUNGEON=  128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 \
          144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 \
          160 161 162 163 164 165 166 167 168
TRAPS=                                        169 170 171 172 173 174 175 \
          176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
EFFECTS=                                                              191 \
          192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 \
          208 209 210 211 212 213 214 215 216 217 218 219
OBJECTS=                                                  220 221 222 223 \
          224 225 226 227 228 229 230 231 232 233 234 235 236
WARNINGS=                                                     237 238 239 \
          240 241 242

Configuring konwert

konwert filters are just executable shell scripts, and it will look for them in your ~/.konwert/filters/ directory. The cp437-UTF8 filter is a good starting-point, copy it into your personal filters directory from /usr/share/konwert/filters/cp437-UTF8. Edit it and remove the -e argument and the text that follows. Rename it 'nethack'. This filter looks for the character set conversion table ~/.konwert/aux/charsets/nethack - that is where you'll map the hexadecimal values of the character codes to actual UTF8 characters. Here's the file I'm using at the moment (I really should get around to specifying characters for those traps):

# DUNGEON
\x80 \x2F
\x81 ┃
\x82 ━
\x83 ┏
\x84 ┓
\x85 ┗
\x86 ┛
\x87 ╋
\x88 ┻
\x89 ┳
\x8A ┫
\x8B ┣
\x8C ▢
\x8D □
\x8E □
\x8F ▣
\x90 ▣
\x91 ▥
\x92 ♣
\x93 ·
\x94 ░
\x95 ▒
\x96 ⌫
\x97 ⌦
\x98 ⌊
\x99 ⌉
\x9A ✟
\x9B ∩
\x9C ♄
\x9D ◡
\x9E ∰
\x9F ⊚
\xA0 ☃
\xA1 ♨
\xA2 ╎
\xA3 ╌
\xA4 ╪
\xA5 ╫
\xA6 ≋
\xA7 ☁
\xA8 ≌
# TRAPS
\xA9 ^
\xAA ^
\xAB ^
\xAC ^
\xAD ^
\xAE ^
\xAF ^
\xB0 ^
\xB1 ^
\xB2 ^
\xB3 ^
\xB4 ^
\xB5 ^
\xB6 ^
\xB7 ^
\xB8 ^
\xB9 ^
\xBA "
\xBB ^
\xBC ^
\xBD ^
\xBE ^
# EFFECTS
\xBF │
\xC0 ─
\xC1 ╲
\xC2 ╱
\xC3 ☢
\xC4 ⚡
\xC5 ❯
\xC6 ❮
\xC7 ◴
\xC8 ◵
\xC9 ◶
\xCA ◷
\xCB ╭
\xCC ─
\xCD ╮
\xCE │
\xCF │
\xD0 ╰
\xD1 ─
\xD2 ╯
\xD3 ╲
\xD4 │
\xD5 ╱
\xD6 ─
\xD7 ╳
\xD8 ─
\xD9 ╱
\xDA │
\xDB ╲
# OBJECTS
\xDC ♅
\xDD ⚔
\xDE ◎
\xDF ◦
\xE0 ☿
\xE1 ☭
\xE2 ♋
\xE3 ⚱
\xE4 ♊
\xE5 ❐
\xE6 /
\xE7 $
\xE8 ♦
\xE9 ●
\xEA ⚈
\xEB ☷
\xEC ✦
# WARNINGS
\xED ¹
\xEE ²
\xEF ³
\xF0 ⁴
\xF1 ⁵
\xF2 ⁶

You can then place whatever UTF8 characters you want into the second column (the \x20 is there to represent a space character that wouldn't otherwise be noticed by konwert).

Running Nethack

All that is left to do is run Nethack:

nethack | konwert nethack