Template:HexRow: Difference between revisions

From OniGalore
Jump to navigation Jump to search
m (enjoy)
 
m (the "Chess position" template was deleted from WP; "Chess diagram" has replaced it, but I assume the syntax is different)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<noinclude>{|border=1 cellspacing=0 </noinclude>
<includeonly>|-style="font-family:courier"
|-style="font-family:courier"
|{{{1|0x00}}}:&nbsp;
!{{{0|0x00}}}
|BGCOLOR="#{{{20|FF}}}{{{37|FF}}}{{{54|FF}}}"|{{{3|00}}}
|BGCOLOR="#{{{17|FF}}}{{{33|FF}}}{{{49|FF}}}"|{{{1|00}}}
|BGCOLOR="#{{{21|FF}}}{{{38|FF}}}{{{55|FF}}}"|{{{4|00}}}
|BGCOLOR="#{{{18|FF}}}{{{34|FF}}}{{{50|FF}}}"|{{{2|00}}}
|BGCOLOR="#{{{22|FF}}}{{{39|FF}}}{{{56|FF}}}"|{{{5|00}}}
|BGCOLOR="#{{{19|FF}}}{{{35|FF}}}{{{51|FF}}}"|{{{3|00}}}
|BGCOLOR="#{{{23|FF}}}{{{40|FF}}}{{{57|FF}}}"|{{{6|00}}}
|BGCOLOR="#{{{20|FF}}}{{{36|FF}}}{{{52|FF}}}"|{{{4|00}}}
|BGCOLOR="#{{{24|FF}}}{{{41|FF}}}{{{58|FF}}}"|{{{7|00}}}
|BGCOLOR="#{{{21|FF}}}{{{37|FF}}}{{{53|FF}}}"|{{{5|00}}}
|BGCOLOR="#{{{25|FF}}}{{{42|FF}}}{{{59|FF}}}"|{{{8|00}}}
|BGCOLOR="#{{{22|FF}}}{{{38|FF}}}{{{54|FF}}}"|{{{6|00}}}
|BGCOLOR="#{{{26|FF}}}{{{43|FF}}}{{{60|FF}}}"|{{{9|00}}}
|BGCOLOR="#{{{23|FF}}}{{{39|FF}}}{{{55|FF}}}"|{{{7|00}}}
|BGCOLOR="#{{{27|FF}}}{{{44|FF}}}{{{61|FF}}}"|{{{10|00}}}
|BGCOLOR="#{{{24|FF}}}{{{40|FF}}}{{{56|FF}}}"|{{{8|00}}}
|BGCOLOR="#{{{28|FF}}}{{{45|FF}}}{{{62|FF}}}"|{{{11|00}}}
|BGCOLOR="#{{{25|FF}}}{{{41|FF}}}{{{57|FF}}}"|{{{9|00}}}
|BGCOLOR="#{{{29|FF}}}{{{46|FF}}}{{{63|FF}}}"|{{{12|00}}}
|BGCOLOR="#{{{26|FF}}}{{{42|FF}}}{{{58|FF}}}"|{{{10|00}}}
|BGCOLOR="#{{{30|FF}}}{{{47|FF}}}{{{64|FF}}}"|{{{13|00}}}
|BGCOLOR="#{{{27|FF}}}{{{43|FF}}}{{{59|FF}}}"|{{{11|00}}}
|BGCOLOR="#{{{31|FF}}}{{{48|FF}}}{{{65|FF}}}"|{{{14|00}}}
|BGCOLOR="#{{{28|FF}}}{{{44|FF}}}{{{60|FF}}}"|{{{12|00}}}
|BGCOLOR="#{{{32|FF}}}{{{49|FF}}}{{{66|FF}}}"|{{{15|00}}}
|BGCOLOR="#{{{29|FF}}}{{{45|FF}}}{{{61|FF}}}"|{{{13|00}}}
|BGCOLOR="#{{{33|FF}}}{{{50|FF}}}{{{67|FF}}}"|{{{16|00}}}
|BGCOLOR="#{{{30|FF}}}{{{46|FF}}}{{{62|FF}}}"|{{{14|00}}}
|BGCOLOR="#{{{34|FF}}}{{{51|FF}}}{{{68|FF}}}"|{{{17|00}}}
|BGCOLOR="#{{{31|FF}}}{{{47|FF}}}{{{63|FF}}}"|{{{15|00}}}
|BGCOLOR="#{{{35|FF}}}{{{52|FF}}}{{{69|FF}}}"|{{{18|00}}}
|BGCOLOR="#{{{32|FF}}}{{{48|FF}}}{{{64|FF}}}"|{{{16|00}}}
|&nbsp;{{{71|°°°°°°°°°°°°°°°°}}}</includeonly><noinclude>
!{{{65|°°°°°°°°°°°°°°°°}}}
Here's an all-ASCII alternative to GIF/PNG snapshots of hex data.
<noinclude>|}


Editable by anyone, "right there", in parallel with related documentation.


Here's an all-ASCII alternative to GIF/PNG snapshots of hex data.
Either embedded in the article using it, or in a subpage of the article.
:(in that case, transcluded and made directly editable via a header)
::(but if one wants to keep the doc in sync, it's not such a good idea)


;Usage
;Usage
The following input :
The following input :
  <nowiki>{|border=1 cellspacing=0 style="font-family:courier"
  <nowiki>{|border=1 cellspacing=0</nowiki>
<nowiki>{{HexRow</nowiki>
  <nowiki>{{HexRow|0x00|</nowiki>
  <nowiki>|0x00</nowiki>
  <nowiki>|01|51|02|00|01|00|00|06|AD|DE|AD|DE|AD|DE|AD|DE|</nowiki>
  <nowiki>|01|51|02|00|01|00|00|06|AD|DE|AD|DE|AD|DE|AD|DE</nowiki>
  <nowiki>|FF|FF|FF|FF|FF|FF|FF|FF|00|00|00|00|00|00|00|00|</nowiki>
  <nowiki>|FF|FF|FF|FF|FF|FF|FF|FF|00|00|00|00|00|00|00|00</nowiki>
  <nowiki>|00|00|00|00|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|</nowiki>
  <nowiki>|00|00|00|00|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF</nowiki>
<nowiki>|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|</nowiki>
  <nowiki>|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00</nowiki>
<nowiki>|Who needs this?°}}</nowiki>
  <nowiki>|°who°needs°this°</nowiki>
<nowiki>{{HexRow|0x10|</nowiki>
<nowiki>|AD|DE|AD|DE|AD|DE|AD|DE|AD|DE|AD|DE|AD|DE|AD|DE|</nowiki>
  <nowiki>|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|</nowiki>
  <nowiki>|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|</nowiki>
<nowiki>|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|</nowiki>
  <nowiki>}}</nowiki>
  <nowiki>}}</nowiki>
<nowiki>|}</nowiki>
produces the following output :
produces the following output :
{|border=1 cellspacing=0 style="font-family:courier"</noinclude>
{|border=1 cellspacing=0
|-
|-style="font-family:courier"
!{{{0|0x00}}}
|{{{0|0x00:&nbsp;}}}
|BGCOLOR="#FF0000"|01
|BGCOLOR="#FF0000"|01
|BGCOLOR="#FF0000"|51
|BGCOLOR="#FF0000"|51
Line 47: Line 54:
|BGCOLOR="#FFFF00"|00
|BGCOLOR="#FFFF00"|00
|BGCOLOR="#FFFF00"|06
|BGCOLOR="#FFFF00"|06
|BGCOLOR="#FFFF00"|AD
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|AD
Line 55: Line 62:
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|DE
!°who°needs°this°
|&nbsp;Who needs this?°
|-style="font-family:courier"
|{{{0|0x10:&nbsp;}}}
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|BGCOLOR="#00FF00"|AD
|BGCOLOR="#00FF00"|DE
|&nbsp;°°°°°°°°°°°°°°°°
|}
|}
 
There are 66 "actual" arguments; they are ''not'' named, but they line up intuitively.
There are 65 arguments; they are ''not'' named, but they line up nicely in a 16x4 lattice.
:(the extra | at the end of a line is part of a hack)
*The first argument is the data's offset (default is 0x00, maybe it should be blank).
*The first argument is the data's offset (default is 0x00, maybe it should be blank).
*The next 16 arguments are the 16 hex bytes.
*The next 16 arguments are the 16 hex bytes.
Line 66: Line 92:
**16 "blue" bytes
**16 "blue" bytes
*Finally, you can add an ASCII translation if you so wish.
*Finally, you can add an ASCII translation if you so wish.
**Most of the time it's actually irrelevant; I'd systematically show all non-printable chars as '''°'''.
**Most of the time it's actually irrelevant
**If all 16 chars are non-printable, leave the last argument blank (the default value is '''°°°°°°°°°°°°°°°°''')
**I'd systematically show nonsensical ASCII as '''°''' : it's less distractive.
</noinclude>
**If all 16 chars are nonsense, simply omit the last argument (the default value is '''°°°°°°°°°°°°°°°°''')
**Same for confirmed garbage in the hex fields : you can fill it with '''°'''.
Only the fixed-size font is specified in this template, as well as bold for offset and ASCII.
 
The rest (cell spacing/padding, border, alignment on page, background color, etc) is set at table level.
</noinclude><noinclude>
 
[[Category:Table templates]]</noinclude>

Latest revision as of 21:21, 27 March 2020

Here's an all-ASCII alternative to GIF/PNG snapshots of hex data.

Editable by anyone, "right there", in parallel with related documentation.

Either embedded in the article using it, or in a subpage of the article.

(in that case, transcluded and made directly editable via a header)
(but if one wants to keep the doc in sync, it's not such a good idea)
Usage

The following input :

{|border=1 cellspacing=0
{{HexRow|0x00|
|01|51|02|00|01|00|00|06|AD|DE|AD|DE|AD|DE|AD|DE|
|FF|FF|FF|FF|FF|FF|FF|FF|00|00|00|00|00|00|00|00|
|00|00|00|00|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|
|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|
|Who needs this?°}}
{{HexRow|0x10|
|AD|DE|AD|DE|AD|DE|AD|DE|AD|DE|AD|DE|AD|DE|AD|DE|
|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|
|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|FF|
|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|
}}
|}

produces the following output :

0x00:  01 51 02 00 01 00 00 06 AD DE AD DE AD DE AD DE  Who needs this?°
0x10:  AD DE AD DE AD DE AD DE AD DE AD DE AD DE AD DE  °°°°°°°°°°°°°°°°

There are 66 "actual" arguments; they are not named, but they line up intuitively.

(the extra | at the end of a line is part of a hack)
  • The first argument is the data's offset (default is 0x00, maybe it should be blank).
  • The next 16 arguments are the 16 hex bytes.
  • Then you have the RGB components of every byte's background :
    • 16 "red" bytes
    • 16 "green" bytes
    • 16 "blue" bytes
  • Finally, you can add an ASCII translation if you so wish.
    • Most of the time it's actually irrelevant
    • I'd systematically show nonsensical ASCII as ° : it's less distractive.
    • If all 16 chars are nonsense, simply omit the last argument (the default value is °°°°°°°°°°°°°°°°)
    • Same for confirmed garbage in the hex fields : you can fill it with °.

Only the fixed-size font is specified in this template, as well as bold for offset and ASCII.

The rest (cell spacing/padding, border, alignment on page, background color, etc) is set at table level.