Changes in uspace/dist/src/c/demos/edit/sheet.c [70b570c:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/c/demos/edit/sheet.c
r70b570c r9d58539 57 57 58 58 #include "sheet.h" 59 #include "sheet_impl.h"60 59 61 60 enum { … … 67 66 68 67 /** Initialize an empty sheet. */ 69 int sheet_create(sheet_t **rsh) 70 { 71 sheet_t *sh; 72 73 sh = calloc(1, sizeof(sheet_t)); 74 if (sh == NULL) 75 return ENOMEM; 76 68 int sheet_init(sheet_t *sh) 69 { 77 70 sh->dbuf_size = INITIAL_SIZE; 78 71 sh->text_size = 0; … … 84 77 list_initialize(&sh->tags); 85 78 86 *rsh = sh;87 79 return EOK; 88 80 } … … 105 97 char *ipp; 106 98 size_t sz; 99 tag_t *tag; 107 100 char *newp; 108 101 … … 127 120 /* Adjust tags. */ 128 121 129 list_foreach(sh->tags, link, tag_t, tag) { 122 list_foreach(sh->tags, link) { 123 tag = list_get_instance(link, tag_t, link); 124 130 125 if (tag->b_off > pos->b_off) 131 126 tag->b_off += sz; … … 151 146 char *spp; 152 147 size_t sz; 148 tag_t *tag; 153 149 char *newp; 154 150 size_t shrink_size; … … 161 157 162 158 /* Adjust tags. */ 163 list_foreach(sh->tags, link, tag_t, tag) { 159 list_foreach(sh->tags, link) { 160 tag = list_get_instance(link, tag_t, link); 161 164 162 if (tag->b_off >= epos->b_off) 165 163 tag->b_off -= sz; … … 266 264 sheet_get_cell_pt(sh, &coord, dir_before, &pt); 267 265 spt_get_coord(&pt, &coord); 268 *length = coord.column ;266 *length = coord.column - 1; 269 267 } 270 268 … … 317 315 } 318 316 319 /** Get a character at spt and return next spt */320 wchar_t spt_next_char(spt_t spt, spt_t *next)321 {322 wchar_t ch = str_decode(spt.sh->data, &spt.b_off, spt.sh->text_size);323 if (next)324 *next = spt;325 return ch;326 }327 328 wchar_t spt_prev_char(spt_t spt, spt_t *prev)329 {330 wchar_t ch = str_decode_reverse(spt.sh->data, &spt.b_off, spt.sh->text_size);331 if (prev)332 *prev = spt;333 return ch;334 }335 336 317 /** Place a tag on the specified s-point. */ 337 318 void sheet_place_tag(sheet_t *sh, spt_t const *pt, tag_t *tag)
Note:
See TracChangeset
for help on using the changeset viewer.