path: root/command.h
blob: 8f6a06a71afdd2791b94da5f38e98cd1cc192d83 (plain) (tree)


/* Copyright (c) 2021 nytpu <alex@nytpu.com>
 * SPDX-License-Identifier: GPL-3.0-only
 * For more license details, see LICENSE or <https://www.gnu.org/licenses/gpl-3.0.html>.

#pragma once
#ifndef _COMMAND_H
#define _COMMAND_H

#include "common.h"

#include <stdbool.h>

struct command {
	// addresses
	// TODO: add mark support and regex.  should marks and regex be
	//       evaluated when parsing or by the command loop?
	int cnt;      // Number of addresses in command: 0, 1, or 2
	RowNum start; // start of range
	RowNum end;   // end of range. also use for individual addresses, as
	              // single-addr commands should use end if range is given

	// commands
	char command; // \0 is the so-called "null" command
	char suffix; // \0 if no suffix

	// should be determinable which is in use via command
	union {
		char *name; // filename given to `f`, `e`, and `r`
		RowNum target_addr; // address given to `m` and `t`
		// TODO: add additional parameters for searches and such

int parse_command(struct command *c, char *l);

#endif // _COMMAND_H