summary refs log tree commit diff stats
path: root/examples/cross_todo/nim_commandline/nimtodo.nim
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cross_todo/nim_commandline/nimtodo.nim')
-rw-r--r--examples/cross_todo/nim_commandline/nimtodo.nim12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/cross_todo/nim_commandline/nimtodo.nim b/examples/cross_todo/nim_commandline/nimtodo.nim
index 4ab17e7a2..339846071 100644
--- a/examples/cross_todo/nim_commandline/nimtodo.nim
+++ b/examples/cross_todo/nim_commandline/nimtodo.nim
@@ -191,7 +191,7 @@ proc parseCmdLine(): TParamConfig =
     abort("Used list options, but didn't specify the list command.", 10)
 
 
-proc generateDatabaseRows(conn: TDbConn) =
+proc generateDatabaseRows(conn: DbConn) =
   ## Adds some rows to the database ignoring errors.
   discard conn.addTodo(1, "Watch another random youtube video")
   discard conn.addTodo(2, "Train some starcraft moves for the league")
@@ -209,7 +209,7 @@ proc generateDatabaseRows(conn: TDbConn) =
   echo("Generated some entries, they were added to your database.")
 
 
-proc listDatabaseContents(conn: TDbConn; listParams: TPagedParams) =
+proc listDatabaseContents(conn: DbConn; listParams: TPagedParams) =
   ## Dumps the database contents formatted to the standard output.
   ##
   ## Pass the list/filter parameters parsed from the commandline.
@@ -239,7 +239,7 @@ proc listDatabaseContents(conn: TDbConn; listParams: TPagedParams) =
       todo.text])
 
 
-proc deleteOneTodo(conn: TDbConn; todoId: int64) =
+proc deleteOneTodo(conn: DbConn; todoId: int64) =
   ## Deletes a single todo entry from the database.
   let numDeleted = conn.deleteTodo(todoId)
   if numDeleted > 0:
@@ -248,7 +248,7 @@ proc deleteOneTodo(conn: TDbConn; todoId: int64) =
     quit("Couldn't delete todo id " & $todoId, 11)
 
 
-proc deleteAllTodos(conn: TDbConn) =
+proc deleteAllTodos(conn: DbConn) =
   ## Deletes all the contents from the database.
   ##
   ## Note that it would be more optimal to issue a direct DELETE sql statement
@@ -273,7 +273,7 @@ proc deleteAllTodos(conn: TDbConn) =
   echo("Deleted $1 todo entries from database." % $counter)
 
 
-proc setTodoCheck(conn: TDbConn; todoId: int64; value: bool) =
+proc setTodoCheck(conn: DbConn; todoId: int64; value: bool) =
   ## Changes the check state of a todo entry to the specified value.
   let
     newState = if value: "checked" else: "unchecked"
@@ -293,7 +293,7 @@ proc setTodoCheck(conn: TDbConn; todoId: int64; value: bool) =
     quit("Error updating todo id $1 to $2." % [$todoId, newState])
 
 
-proc addTodo(conn: TDbConn; priority: int; tokens: seq[string]) =
+proc addTodo(conn: DbConn; priority: int; tokens: seq[string]) =
   ## Adds to the database a todo with the specified priority.
   ##
   ## The tokens are joined as a single string using the space character. The
Kartik K. Agaram <vc@akkartik.com> 2022-05-11 13:01:13 -0700 intermingle freehand line drawings with text' href='/akkartik/lines.love/commit/button.lua?id=475bbd70efec08f4279f42b044dfe3bb9f35d63e'>475bbd7 ^
490f10c ^
9c72ff1 ^


8747415 ^
490f10c ^
475bbd7 ^

9c72ff1 ^
475bbd7 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

                                                                              





                                                                            
 
                                          



                                      
                                                                            
                                                                            
                                             
                                             


                                
                                                                              


                                      

                              
                                              
                                                             
                                               


                               
           
         

       
                                         
   
-- Simple immediate-mode buttons with (currently) just an onpress1 handler for
-- the left button.
--
-- Buttons can nest in principle, though I haven't actually used that yet.
--
-- Don't rely on the order in which handlers are run. Within any widget, all
-- applicable button handlers will run. If _any_ of them returns true, the
-- event will continue to propagate elsewhere in the widget.

-- draw button and queue up event handlers
function button(State, name, params)
  if State.button_handlers == nil then
    State.button_handlers = {}
  end
  love.graphics.setColor(params.bg.r, params.bg.g, params.bg.b, params.bg.a)
  love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5)
  if params.icon then params.icon(params) end
  table.insert(State.button_handlers, params)
end

-- process button event handlers
function mouse_press_consumed_by_any_button_handler(State, x, y, mouse_button)
  if State.button_handlers == nil then
    return
  end
  local button_pressed = false
  local consume_press = true
  for _,ev in ipairs(State.button_handlers) do
    if x>ev.x and x<ev.x+ev.w and y>ev.y and y<ev.y+ev.h then
      if ev.onpress1 and mouse_button == 1 then
        button_pressed = true
        if ev.onpress1() then
          consume_press = false
        end
      end
    end
  end
  return button_pressed and consume_press
end