[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [CDK] A few problems, remarks and suggestions, mostly concerning the

From: Stéphane Goujet
Subject: Re: [CDK] A few problems, remarks and suggestions, mostly concerning the Scroll widget
Date: Sun, 6 Jan 2019 19:09:21 +0100 (CET)
User-agent: Alpine 2.21.1 (LNX 216 2017-09-19)

On Tue, 1 Jan 2019, Thomas Dickey wrote:

On Mon, Dec 31, 2018 at 05:04:15PM +0100, Stéphane Goujet wrote:

Was I right, that there is no official function to get the number of items
in the scroll list? (besides using this one in this 'unexpected' way)

well... an application could just look at the data structure, since
that's not opaque (a function would be nicer, agreed)

Well yeah... but then that means that the fields should be documented (and some level of backward compatibility assured in the future). Otherwise it doesn't feel very 'safe', especially since there are many setters and getters around: one has the feeling every regular action should go through setters and getters.

  One last (unrelated) point. I had to implement the following function:

static char *getScrollTitle(CDKSCROLL *scrollp) {
        size_t total_len=0;
        int lines_nb;
        int i, pos;
        char *title, *temp;

        lines_nb = TitleLinesOf(scrollp);
        for(i=0; i<lines_nb; i++) {
                total_len += TitleLenOf(scrollp)[i];
        title = malloc(total_len + lines_nb);
        if(!title) return NULL;
        pos = 0;
        for(i=0; i<lines_nb; i++) {
                temp = chtype2Char(TitleOf(scrollp)[i]);
                strcpy(title+pos, temp);
                pos += TitleLenOf(scrollp)[i];
                if(i < lines_nb - 1) {
                        title[pos] = '\n';
        return title;
(don't trust my code, I haven't even tested it with multiline titles)

(My purpose wass to be able to destroy and recreate my Scroll widgets after I get a KEY_RESIZE, so I needed to copy the content of the old widget into a new one: items, selected_index and... title, for which there was no getter.)

I saw cdk_obks has cleanCdkTitle() and setCdkTitle(), but it has no getCdkTitle(). Do you think it would be a good idea to add someyhing like that to that part of the API?

Faithfully yours,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]