Skip to content
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

Fixed Cursor Bug. #92

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/mruby-zest/mrblib/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def initialize(vg, string, width, height)
calc_cursor_x
end

attr_reader :cursor_row

def check_args(vg, string, width, height)
if(!([Float,Integer].include? width.class))
raise TypeError.new("Invalid width <#{width.inspect}> expected Integer/Float, got #{width.class}")
Expand Down Expand Up @@ -138,11 +140,9 @@ def string_to_lines
@activew += @widths[i]
elsif(@chrcls[i] == :space)
flush_word_buffer()

push_char(@string[i], @widths[i])
elsif(@chrcls[i] == :line)
flush_word_buffer()

@line_widths[@active_line] = @lastw
@lastw = @activew = 0
@active_line += 1
Expand Down
5 changes: 3 additions & 2 deletions src/mruby-zest/qml/TextEdit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ Widget {
pos = self.label.length
pos = @edit.pos if @edit
ll = self.label
cursor_row = @edit.cursor_row
if(k.ord == 8)
pos -= 1
if(pos >= ll.length)
self.label = ll.slice(0, ll.length-1)
elsif(pos >= 0)
self.label = ll.slice(0, pos) + ll.slice(pos+1, ll.length)
self.label = ll.slice(0, pos+cursor_row) + ll.slice(pos+1+cursor_row, ll.length)
end
else
self.label = ll.insert(pos, k)
self.label = ll.insert(pos+cursor_row, k)
end
ll = self.label
self.valueRef.value = ll if self.valueRef
Expand Down