Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
srp committed Jan 15, 2015
1 parent cbf0745 commit 307d525
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
48 changes: 32 additions & 16 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,27 +363,41 @@ function char_move_right(buf::IOBuffer)
end

function char_move_word_right(buf::IOBuffer, is_delimiter=is_non_word_char)
while !eof(buf) && is_delimiter(char_move_right(buf))
out = IOBuffer()
while !eof(buf)
c = char_move_right(buf)
write(out, c)
is_delimiter(c) || break
end
while !eof(buf)
pos = position(buf)
if is_delimiter(char_move_right(buf))
c = char_move_right(buf)
if is_delimiter(c)
seek(buf, pos)
break
end
write(out, c)
end
takebuf_string(out)
end

function char_move_word_left(buf::IOBuffer, is_delimiter=is_non_word_char)
while position(buf) > 0 && is_delimiter(char_move_left(buf))
out = IOBuffer()
while position(buf) > 0
c = char_move_left(buf)
write(out, c)
is_delimiter(c) || break
end
while position(buf) > 0
pos = position(buf)
if is_delimiter(char_move_left(buf))
c = char_move_left(buf)
if is_delimiter(c)
seek(buf, pos)
break
end
write(out, c)
end
takebuf_string(out)
end

char_move_word_right(s) = char_move_word_right(buffer(s))
Expand Down Expand Up @@ -554,31 +568,33 @@ function edit_werase(s)
edit_werase(buffer(s)) ? refresh_line(s) : pop_undo(s)
end

function edit_delete_prev_word(buf::IOBuffer)
function edit_delete_prev_word(s)
buf = buffer(s)
pos1 = position(buf)
char_move_word_left(buf)
killedword = char_move_word_left(buf)
pos0 = position(buf)
pos0 < pos1 || return false
seek(pos1)
push_undo(s)
s.kill_buffer = s.key_repeats > 0 ? s.kill_buffer * killedword : killedword
splice_buffer!(buf, pos0:pos1-1)
refresh_line(s)
true
end
function edit_delete_prev_word(s)
push_undo(s)
edit_delete_prev_word(buffer(s)) ? refresh_line(s) : pop_undo(s)
end

function edit_delete_next_word(buf::IOBuffer)
function edit_delete_next_word(s)
buf = buffer(s)
pos0 = position(buf)
char_move_word_right(buf)
killedword = char_move_word_right(buf)
pos1 = position(buf)
pos0 < pos1 || return false
seek(buf, pos0)
push_undo(s)
s.kill_buffer = s.key_repeats > 0 ? s.kill_buffer * killedword : killedword
splice_buffer!(buf, pos0:pos1-1)
refresh_line(s)
true
end
function edit_delete_next_word(s)
push_undo(s)
edit_delete_next_word(buffer(s)) ? refresh_line(s) : pop_undo(s)
end

function edit_yank(s::MIState)
push_undo(s)
Expand Down
1 change: 0 additions & 1 deletion base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ function readuntil(s::IO, t::AbstractString)
return takebuf_string(out)
end


readline(s::IO) = readuntil(s, '\n')
readchomp(x) = chomp!(readall(x))

Expand Down

0 comments on commit 307d525

Please sign in to comment.