-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development branch #101
base: master
Are you sure you want to change the base?
Development branch #101
Changes from all commits
7891e4a
eb1320c
c660be2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,28 +50,72 @@ Widget { | |
(0...l.length).each do |i| | ||
l[i] = "?" if l.getbyte(i) > 127 | ||
end | ||
vg.text(8,h/2,l) | ||
bnd = vg.text_bounds(0,0,l) | ||
if(@state) | ||
vg.text(8+bnd,h/2,"|") | ||
|
||
@edit ||= EditRegion.new($vg, self.label, w-20, h*0.8) | ||
@edit.each_string do |x, y, str, cursor| | ||
if(cursor == false) | ||
vg.text(x+10, y, str) | ||
else | ||
if(@state) | ||
vg.text_align NVG::ALIGN_LEFT| NVG::ALIGN_MIDDLE | ||
vg.text(x+10, y, str) | ||
end | ||
end | ||
end | ||
|
||
} | ||
|
||
function onKey(k, mode) | ||
{ | ||
return if mode != "press" | ||
pos = self.label.length | ||
pos = @edit.pos if @edit | ||
ll = self.label | ||
|
||
cursorrow = @edit.cursor_row | ||
|
||
if(k.ord == 8) | ||
self.label = self.label[0...-1] | ||
elsif k.ord >= 32 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line disappeared with your change, and it's important. This is how TextLine ignores most of the non-printable characters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @pgervais , There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to double check we're talking about the same thing. I was referring to the "elsif k.ord >= 32" line. Is that what you meant? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly an off-topic comment, but make sure to use a581036 in your branch if you're experiencing problems with creating shorter strings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Phillip, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can implement it the way you prefer. What is most important is to make sure values of k.ord less than 32 are ignored (with the exception of 8) |
||
self.label += k | ||
pos -= 1 | ||
if(pos >= ll.length) | ||
self.label = ll[0...-1] | ||
elsif(pos >= 0) | ||
self.label = ll.slice(0, pos+cursorrow) + ll.slice(pos+1+cursorrow, ll.length) | ||
end | ||
else | ||
self.label = ll.insert(pos+cursorrow, k) | ||
end | ||
ll = self.label | ||
whenValue.call if whenValue | ||
valueRef.value = self.label if valueRef | ||
@edit = EditRegion.new($vg, ll, w-20, 0.8*h) | ||
if(k.ord == 8) | ||
@edit.pos = pos | ||
else | ||
@edit.pos = pos+1 | ||
end | ||
damage_self | ||
} | ||
|
||
|
||
function onSpecial(k, mode) | ||
{ | ||
return if @edit.nil? | ||
return if mode != :press | ||
|
||
if(k == :left) | ||
@edit.left | ||
elsif(k == :right) | ||
@edit.right | ||
end | ||
|
||
@state = true | ||
now = Time.new | ||
@next = now + 0.7 | ||
damage_self | ||
} | ||
|
||
function onMerge(val) | ||
{ | ||
self.label = val.label | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cursor_row
instead ofcursorrow
@edit.cursor_row
, which reduces the mental load (we don't have to think whether to spell it one way or another)