\b Escape character not working in drawings - Script Writing - CHDK Forum

\b Escape character not working in drawings

  • 2 Replies
  • 3278 Views
*

Offline otosclerosi

  • *
  • 22
  • Canon IXUS160 with CHDK 1.5
\b Escape character not working in drawings
« on: 06 / December / 2016, 12:27:59 »
Advertisements
I'm trying to do a sort of keyboard for my camera
i was thinking how to include backspace
i have
Code: [Select]
stringa="example" and i want to delete the "e", so i tried
Code: [Select]
stringa=stringa.."\b \b"which is supposed to add to "example" a backspace escape character, a space (overriding the "e") and another backspace to set the cursor to the right position...
but instead of a backspace, a white box character is displayed, like "example[] []" when i try to do
Code: [Select]
draw.add("string",..., stringa)
just wondering what i am doing wrong and how to achieve the result

edit: in "CHDK Lua local" run on a pc it works, on the camera it doesn't. Same results with
Code: [Select]
stringa="ciao"
print(stringa.."\n")
stringa=stringa.."\b \b"
print(stringa)
wait_click(0)
on pc it shows "cia", on the camera it shows "ciao[] []"
« Last Edit: 06 / December / 2016, 13:08:19 by otosclerosi »
Can a kangaroo jump higher than a house?
Of course, a house doesn’t jump at all.

*

Offline reyalp

  • ******
  • 14125
Re: \b Escape character not working in drawings
« Reply #1 on: 06 / December / 2016, 13:39:07 »
CHDK text output doesn't generally understand control characters, except for some specific cases involving things like newlines.

Note that there is already support for keyboard input with the textbox function http://chdk.wikia.com/wiki/Script_commands#textbox

If you want to roll your own, you'll have to manage drawing the text and cursor yourself.

There's a Lua based text editor in scripts/editor/edi.lua
Don't forget what the H stands for.

*

Offline otosclerosi

  • *
  • 22
  • Canon IXUS160 with CHDK 1.5
Re: \b Escape character not working in drawings
« Reply #2 on: 06 / December / 2016, 17:48:14 »
I mean something like a graphical virtual keyboard to use in drawings project (i.e. that rpg)...
ok so i'll use a workaround by splitting the string and substituting last char with a ""...
something similar to
Code: [Select]
for word in string.gmatch(stringa, '([^--[[HERE WILL BE THE RIGHT DELIMITER]] ]+)') do
--[[HERE I WILL DETECT THE LAST CHAR AND SUBSTITUTE IT]]
end
ty for the clarification...it should work...if it works, i'll post in complete scripts

Edit_1: in fact, working method
Code: [Select]

        stringa="ciao"
local splitted=""
for i = 1, #stringa do
          local c = stringa:sub(i,i)
  if i==#stringa then
    lastchar=c
  else
    splitted=splitted..c
  end
        end
stringa=splitted

« Last Edit: 06 / December / 2016, 18:02:38 by otosclerosi »
Can a kangaroo jump higher than a house?
Of course, a house doesn’t jump at all.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal