Changeset 8e7c9fe in mainline for uspace/dist/src/c/demos/edit/sheet.c
- Timestamp:
- 2014-09-12T03:45:25Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/c/demos/edit/sheet.c
r3eb0c85 r8e7c9fe 57 57 58 58 #include "sheet.h" 59 #include "sheet_impl.h" 59 60 60 61 enum { … … 66 67 67 68 /** Initialize an empty sheet. */ 68 int sheet_init(sheet_t *sh) 69 { 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 70 77 sh->dbuf_size = INITIAL_SIZE; 71 78 sh->text_size = 0; … … 77 84 list_initialize(&sh->tags); 78 85 86 *rsh = sh; 79 87 return EOK; 80 88 } … … 97 105 char *ipp; 98 106 size_t sz; 99 tag_t *tag;100 107 char *newp; 101 108 … … 120 127 /* Adjust tags. */ 121 128 122 list_foreach(sh->tags, link) { 123 tag = list_get_instance(link, tag_t, link); 124 129 list_foreach(sh->tags, link, tag_t, tag) { 125 130 if (tag->b_off > pos->b_off) 126 131 tag->b_off += sz; … … 146 151 char *spp; 147 152 size_t sz; 148 tag_t *tag;149 153 char *newp; 150 154 size_t shrink_size; … … 157 161 158 162 /* Adjust tags. */ 159 list_foreach(sh->tags, link) { 160 tag = list_get_instance(link, tag_t, link); 161 163 list_foreach(sh->tags, link, tag_t, tag) { 162 164 if (tag->b_off >= epos->b_off) 163 165 tag->b_off -= sz; … … 264 266 sheet_get_cell_pt(sh, &coord, dir_before, &pt); 265 267 spt_get_coord(&pt, &coord); 266 *length = coord.column - 1;268 *length = coord.column; 267 269 } 268 270 … … 315 317 } 316 318 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 317 336 /** Place a tag on the specified s-point. */ 318 337 void sheet_place_tag(sheet_t *sh, spt_t const *pt, tag_t *tag)
Note:
See TracChangeset
for help on using the changeset viewer.