-- text editor, particularly text drawing, horizontal wrap, vertical scrolling Text = {} -- draw a line starting from startpos to screen at y between State.left and State.right -- return the final y, and position of start of final screen line drawn function Text.draw(State, line_index, y, startpos) local line = State.lines[line_index] local line_cache = State.line_cache[line_index] line_cache.starty = y line_cache.startpos = startpos -- wrap long lines local x = State.left local pos = 1 local screen_line_starting_pos = startpos Text.compute_fragments(State, line_index) for _, f in ipairs(line_cache.fragments) do App.color(Text_color) local frag, frag_text = f.data, f.text local frag_len = utf8.len(frag) --? print('text.draw:', frag, 'at', line_index,pos, 'after', x,y) if pos < startpos then -- render nothing --? print('skipping', frag) else -- render fragment local frag_width = App.width(frag_text) if x + frag_width > State.right then assert(x > State.left) -- no overfull lines y = y + State.line_height if y + State.line_height > App.screen.height then return y, screen_line_starting_pos end screen_line_starting_pos = pos x = State.left end if State.selection1.line then local lo, hi = Text.clip_selection(State, line_index, pos, pos+frag_len) Text.draw_highlight(State, line, x,y, pos, lo,hi) end App.screen.draw(frag_text, x,y) -- render cursor if necessary if line_index == State.cursor1.line then if pos <= State.cursor1.pos and pos + frag_len > State.cursor1.pos then if State.search_term then if State.lines[State.cursor1.line].data:sub(State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term)-1) == State.search_term then local lo_px = Text.draw_highlight(State, line, x,y, pos, State.cursor1.pos, State.cursor1.pos+utf8.len(State.search_term)) App.color(Text_color) love.graphics.print(State.search_term, x+lo_px,y) end else Text.draw_cursor(State, x+Text.x(frag, State.cursor1.pos-pos+1), y) end end end x = x + frag_width end pos = pos + frag_len end if State.search_term == nil then if line_index == State.cursor1.line and State.cursor1.pos == pos then Text.draw_cursor(State, x, y) end end return y, screen_line_starting_pos end function Text.draw_cursor(State, x, y) -- blink every 0.5s if math.floor(Cursor_time*2)%2 == 0 then App.color(Cursor_color) love.graphics.rectangle('fill', x,y, 3,State.line_height) App.color(Text_color) end State.cursor_x = x State.cursor_y = y+State.line_height end function Text.populate_screen_line_starting_pos(State, line_index) local line = State.lines[line_index] local line_cache = State.line_cache[line_index] if line_cache.screen_line_starting_pos then return end -- duplicate some logic from Text.draw Text.compute_fragments(State, line_index) line_cache.screen_line_starting_pos = {1} local x = State.left local pos = 1 for _, f in ipairs(line_cache.fragments) do local frag, frag_text = f.data, f.text -- render fragment local frag_width = App.width(frag_text) if x + frag_width > State.right then x = State.left table.insert(line_cache.screen_line_starting_pos, pos) end x = x + frag_width local frag_len = utf8.len(frag) pos = pos + frag_len end end function Text.compute_fragments(State, line_index) --? print('compute_fragments', line_index, 'between', State.left, State.right) local line = State.lines[line_index] local line_cache = State.line_cache[line_index] if line_cache.fragment
Using DSCIP
================================================================================
Using DSCIP is extremely simple, there's two ways you can run it.
A. Running it as a cronjob that runs periodically.
B. Running it as a daemon that runs continually.
Funcionally, these two methods work about the same, but depending on your
platform, one may be easier to set up than the other. I personally recommend
setting it up as a cronjob over a daemon. You can do this on most unix systems
by running `crontab -e -u build_user` and adding:
* * * * * /home/build_user/program/dscip
As for how to make it run as a daemon, that depends on the platform you are
running it on, so refer to your OS's documentation for that.
Be sure to change the variables in config.sh to suit your projects needs.
Quirks:
When running it on windows, you should use MSYS2.