source: mainline/uspace/app/edit/sheet.h@ 86018c1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 86018c1 was 3052ff4, checked in by Jiri Svoboda <jiri@…>, 16 years ago

Add simple text editor.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2009 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup edit
30 * @{
31 */
32/**
33 * @file
34 */
35
36#ifndef SHEET_H__
37#define SHEET_H__
38
39#include <adt/list.h>
40#include <sys/types.h>
41#include <bool.h>
42
43/** Direction (in linear space) */
44enum dir_spec {
45 /** Before specified point */
46 dir_before,
47 /** After specified point */
48 dir_after
49};
50
51/** Sheet */
52typedef struct {
53 /* Note: This structure is opaque for the user. */
54
55 size_t text_size;
56 size_t dbuf_size;
57 char *data;
58
59 link_t tags_head;
60} sheet_t;
61
62/** Character cell coordinates
63 *
64 * These specify a character cell. The first cell is (1,1).
65 */
66typedef struct {
67 int row;
68 int column;
69} coord_t;
70
71/** S-point
72 *
73 * An s-point specifies the boundary between two successive characters
74 * in the linear file space (including the beginning of file or the end
75 * of file. An s-point only remains valid as long as no modifications
76 * (insertions/deletions) are performed on the sheet.
77 */
78typedef struct {
79 /* Note: This structure is opaque for the user. */
80 sheet_t *sh;
81 size_t b_off;
82} spt_t;
83
84/** Tag
85 *
86 * A tag is similar to an s-point, but remains valid over modifications
87 * to the sheet. A tag tends to 'stay put'. Any tag must be properly
88 * removed from the sheet before it is deallocated by the user.
89 */
90typedef struct {
91 /* Note: This structure is opaque for the user. */
92
93 /** Link to list of all tags in the sheet (see sheet_t.tags_head) */
94 link_t link;
95 sheet_t *sh;
96 size_t b_off;
97} tag_t;
98
99extern int sheet_init(sheet_t *);
100extern int sheet_insert(sheet_t *, spt_t *, enum dir_spec, char *);
101extern int sheet_delete(sheet_t *, spt_t *, spt_t *);
102extern void sheet_copy_out(sheet_t *, spt_t const *, spt_t const *, char *,
103 size_t, spt_t *);
104extern void sheet_get_cell_pt(sheet_t *, coord_t const *, enum dir_spec,
105 spt_t *);
106extern void sheet_get_row_width(sheet_t *, int, int *);
107extern void sheet_get_num_rows(sheet_t *, int *);
108extern void spt_get_coord(spt_t const *, coord_t *);
109extern bool spt_equal(spt_t const *, spt_t const *);
110
111extern void sheet_place_tag(sheet_t *, spt_t const *, tag_t *);
112extern void sheet_remove_tag(sheet_t *, tag_t *);
113extern void tag_get_pt(tag_t const *, spt_t *);
114
115#endif
116
117/** @}
118 */
Note: See TracBrowser for help on using the repository browser.