Page 1 of 1

Unicode Viewer 1.1c

Posted: Fri Oct 20, 2017 6:33 pm
by rbytes
You can select your preferred entry point into the Unicode table by typing a byte value 0 - 255 into the bottom left box. I added error checking in this version to ensure that any value entered is 0 - 255 inclusive. Values outside of that range are ignored.

Code: Select all

''
Unicode Viewer 1.1c by rbytes
October 2017

1.1
  - scales the screen to fit any display
''

' hide the control menu - screenwidth increases by 48 points
#.scrview(#.normal)

' get screen size and calculate scaling for this device
x,y = #.scrsize()
'#.output(x + #.lf + y)    uncomment this line to see your device's screen size
rw = x/1280 ; rh = y/853   ' virtual size of rbytes' tablet screen
s = 1
i = 1
u = 0
r = 26h '00h  '26h gives good emoticons
shft = 0
cp = 1
flag = 1

' draw title
#.fontsize(25*rw)
#.fontname("Papyrus")
#.drawtext(500*rw,25*rh,"UNICODE VIEWER")
fn = "address.txt"

' create button template
h = #.button ; h.height = 70*rh
h.width = 100*rw ; h.y = 710*rh
h.fontsize = 20*rw ; h.fontname = "Papyrus"
h.fontcolor(1,1,1)

' create buttons from template
f,g,j,k = h ; f.x = 370*rw ; g.x = 820*rw
j.x = 520*rw ; k.x = 670*rw
f.image = "Fontview/redbutt.png"
g.image = "Fontview/greenbutt.png"
j.image = "Fontview/bluebutt.png"
k.image = "Fontview/yellowbutt.png"
f.text = "STOP" ; g.text = "SAVE"
j.text = "PREV" ; k.text = "NEXT"
#.show(f,g,j,k)
 
' create textboxes to display selected character and address
d,e,ez = #.textbox
d.width = 80*rw
d.height = 40*rh
d.y = 644*rh
d.text = ""
e,o = d
e.x = 610*rw
o.x = 1030*rw
d.x = 730*rw
ez.x = 190*rw
ez.y = 640*rh
ez.edit = 1
ez.text = ""
ez.multi = 0
ez.width = 50*rw
ez.height = 40*rh
#.show(d,e,ez,o)
#.fontsize(18*rw)
#.drawtext(187*rw,610*rh,"0 - 255")
#.drawtext(605*rw,610*rh,"Hex Bytes")
#.drawtext(725*rw,610*rh,"Dec Bytes")
#.drawtext(1030*rw,610*rh,"Unicode #")
#.drawrect(510*rw,620*rh,570*rw,680*rh)
#.drawrect(610*rw,640*rh,690*rw,680*rh)
#.drawrect(730*rw,640*rh,810*rw,680*rh)
#.drawrect(1030*rw,640*rh,1110*rw,680*rh)

' create button matrix
' define template button and set common parameters
q=#.button
q.width = 60*rw
q.height = 60*rh
q.text = ""
q.fontsize = 30*rw
q.image = "Fontview/whbutt.png"

' buttons to display short messages
w=#.button
w.image = "Fontview/transp.png"
p,m = w
p.fontsize = 36*rw
w.fontsize = 20*rw
m.fontsize = 20*rw
p.text = ""
p.x = 510*rw
p.y = 620*rh
w.x = 300*rw
m.x = 840*rw
m.y,w.y = 640*rh
#.show(p)
m.text = "Address saved"
w.text = "Copied to clipboard:"

' create 128 buttons in a 16 x 8 matrix
> t, 1..128
  
  ' create button name in array, copy from button template q
  b[t] = q

  ' position and draw the buttons
  a[i] = t-1
  i += 1
  a[i] = r '00h  26h
  i += 1
  ~b[t].text = #.mid(#.str(a),t,1)
  ~b[t].x = 60*rw + s*65*rw
  ~b[t].y = 80*rh + u*65*rh
  #.show(~b[t])

' form the rows
s += 1
  ? s > 16
    s = 1
    u += 1
  .
<

' select button 1
c = ~b[1]
c.image = "Fontview/grbutt.png"
flag = 1
p.text = c.text
d.text = 0 + shft + " " + r
'pr1 = "0"
'pr2 = ""
e.text = #.str(0 + shft,"x")+"h" + " " + #.str(r,"x")+"h"
o.text = 1 + shft + r*256
ez.text = r

' main program loop
>
  ? #.act(f)      ' stop button
    #.end()
  .

  ? #.act(ez)      ' textbox high byte entry
    'r = ez.text
    'r = #.val(#.str(ez.text))
    rb = ez.text
    rn = #.int(#.val(ez.text))
    ? rn>-1 & rn < 256
      r = rn
      shft = 0
      drawit <->
    !
      ez.text = rb
    .
    '#.output(r)   ' uncomment this line to test textbox ez input
  .

  ? #.act(g)      ' save button
    ? #.fexist(fn), #.fdelete(fn)
    #.writeline(fn,flag-1 + shft)
    #.writeline(fn,r)
    #.show(m)
    #.delay(1)
    #.hide(m)
  .

  ? #.act(j)      ' prev button; move down 128 bytes
    ? r > 00h
      z.image = "Fontview/whbutt.png"
      ? shft = 128
        shft=0
      !
        r -= 01h
        shft=128
      .
      ''
      c = ~b[1]
      c.image = "Fontview/grbutt.png"
      flag = 1
      p.text = c.text
      d.text = 0 + shft + " " + r
      ''
      drawit <->
    .
  .
 
  ? #.act(k)      ' next button; move up 128 bytes
    ? r < ffh
      z.image = "Fontview/whbutt.png"
      ? shft = 0
        shft=128
      !
        r += 01h
        shft=0
      .
      ''
      c = ~b[1]
      c.image = "Fontview/grbutt.png"
      flag = 1
      p.text = c.text
      d.text = 0 + shft + " " + r
      ''
      drawit <->
    .
  .

  > i, 1..#.size(b,1)
    c = ~b[i]
    ? flag, z = ~b[flag]
    ? #.act(c)
      c.image = "Fontview/grbutt.png"
      ? flag, z.image = "Fontview/whbutt.png"
      p.text = c.text
      d.text = i-1 + shft + " " + r
      o.text = i-1 + shft + r * 256
      e.text = #.str(i - 1 + shft,"x")+"h" + " " + #.str(r,"x")+"h"
      flag = i
      #.clipboard(c.text)
      #.show(w)
      #.delay(1)
      #.hide(w)
    .
  <
#.relax()
<

:drawit
i = 1
ez.text = #.str(r)
> t, 1..128
  a[i] = t-1+shft
  i += 1
  a[i] = r '00h  26h
  i += 1
  ~b[t].text = #.mid(#.str(a),t,1)
<
<-