Changeset 15d0046 in mainline for uspace/dist/src/c/demos/edit/sheet.c


Ignore:
Timestamp:
2014-09-12T13:22:33Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b20126
Parents:
8db09e4 (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.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/dist/src/c/demos/edit/sheet.c

    r8db09e4 r15d0046  
    5757
    5858#include "sheet.h"
     59#include "sheet_impl.h"
    5960
    6061enum {
     
    6667
    6768/** Initialize an empty sheet. */
    68 int sheet_init(sheet_t *sh)
    69 {
     69int 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
    7077        sh->dbuf_size = INITIAL_SIZE;
    7178        sh->text_size = 0;
     
    7784        list_initialize(&sh->tags);
    7885
     86        *rsh = sh;
    7987        return EOK;
    8088}
     
    97105        char *ipp;
    98106        size_t sz;
    99         tag_t *tag;
    100107        char *newp;
    101108
     
    120127        /* Adjust tags. */
    121128
    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) {
    125130                if (tag->b_off > pos->b_off)
    126131                        tag->b_off += sz;
     
    146151        char *spp;
    147152        size_t sz;
    148         tag_t *tag;
    149153        char *newp;
    150154        size_t shrink_size;
     
    157161
    158162        /* 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) {
    162164                if (tag->b_off >= epos->b_off)
    163165                        tag->b_off -= sz;
     
    264266        sheet_get_cell_pt(sh, &coord, dir_before, &pt);
    265267        spt_get_coord(&pt, &coord);
    266         *length = coord.column - 1;
     268        *length = coord.column;
    267269}
    268270
     
    315317}
    316318
     319/** Get a character at spt and return next spt */
     320wchar_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
     328wchar_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
    317336/** Place a tag on the specified s-point. */
    318337void sheet_place_tag(sheet_t *sh, spt_t const *pt, tag_t *tag)
Note: See TracChangeset for help on using the changeset viewer.