commands.c 1.97 KB
Newer Older
Moritz Lipp's avatar
Moritz Lipp committed
1 2 3
/* See LICENSE file for license and copyright information */

#include "commands.h"
Moritz Lipp's avatar
Moritz Lipp committed
4
#include "zathura.h"
5
#include "print.h"
Moritz Lipp's avatar
Moritz Lipp committed
6 7

bool
Moritz Lipp's avatar
Moritz Lipp committed
8
cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list)
Moritz Lipp's avatar
Moritz Lipp committed
9 10 11 12 13
{
  return true;
}

bool
Moritz Lipp's avatar
Moritz Lipp committed
14
cmd_bookmark_delete(girara_session_t* session, girara_list_t* argument_list)
Moritz Lipp's avatar
Moritz Lipp committed
15 16 17 18 19
{
  return true;
}

bool
Moritz Lipp's avatar
Moritz Lipp committed
20
cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list)
Moritz Lipp's avatar
Moritz Lipp committed
21 22 23 24 25
{
  return true;
}

bool
Moritz Lipp's avatar
Moritz Lipp committed
26
cmd_close(girara_session_t* session, girara_list_t* argument_list)
Moritz Lipp's avatar
Moritz Lipp committed
27
{
28 29 30
  g_return_val_if_fail(session != NULL, false);
  g_return_val_if_fail(session->global.data != NULL, false);
  zathura_t* zathura = session->global.data;
31 32 33 34
  if (zathura->document == NULL) {
    // nothing needs to be done
    return true;
  }
35 36

  document_close(zathura);
Moritz Lipp's avatar
Moritz Lipp committed
37

Moritz Lipp's avatar
Moritz Lipp committed
38 39 40 41
  return true;
}

bool
Moritz Lipp's avatar
Moritz Lipp committed
42
cmd_info(girara_session_t* session, girara_list_t* argument_list)
Moritz Lipp's avatar
Moritz Lipp committed
43 44 45 46
{
  return true;
}

47 48 49
bool
cmd_open(girara_session_t* session, girara_list_t* argument_list)
{
Sebastian Ramacher's avatar
Sebastian Ramacher committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
  g_return_val_if_fail(session != NULL, false);
  g_return_val_if_fail(session->global.data != NULL, false);
  zathura_t* zathura = session->global.data;

  if (zathura->document) {
    document_close(zathura);
  }

  const int argc = girara_list_size(argument_list);
  if (argc > 2) {
    girara_error("too many arguments");
    return false;
  }
  else if (argc >= 1) {
    document_open(zathura, girara_list_nth(argument_list, 0), (argc == 2) ? girara_list_nth(argument_list, 1) :  NULL);
  }
  else {
    girara_error("no arguments");
    return false;
  }

71 72 73
  return true;
}

Moritz Lipp's avatar
Moritz Lipp committed
74
bool
Moritz Lipp's avatar
Moritz Lipp committed
75
cmd_print(girara_session_t* session, girara_list_t* argument_list)
Moritz Lipp's avatar
Moritz Lipp committed
76
{
77 78 79 80 81 82 83 84 85
  g_return_val_if_fail(session != NULL, false);
  g_return_val_if_fail(session->global.data != NULL, false);
  zathura_t* zathura = session->global.data;

	if (zathura->document == NULL) {
		girara_error("no document as been opened");
		return false;
	}

Sebastian Ramacher's avatar
Sebastian Ramacher committed
86
	print((zathura_t*) session->global.data);
87

Moritz Lipp's avatar
Moritz Lipp committed
88 89 90 91
  return true;
}

bool
Moritz Lipp's avatar
Moritz Lipp committed
92
cmd_save(girara_session_t* session, girara_list_t* argument_list)
Moritz Lipp's avatar
Moritz Lipp committed
93 94 95
{
  return true;
}