Re: [dev] [st] [PATCH] Use worddelimiters for word selection over wrapped lines.

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Wed, 4 Jun 2014 21:32:11 +0200

A few style questions:

> - if(*y > 0 && term.line[*y - 1][term.col-1].mode
> - & ATTR_WRAP) {
> + if(*y > 0 && term.line[*y-1][term.col-1].mode & ATTR_WRAP
> + && !strchr(worddelimiters,
> + term.line[*y-1][term.col-1].c[0])) {

The term "term.line[*y-1][term.col-1]" appears twice in a very long
expression. I think the use of a pointer can help a bit here with
something like:

                                if(*y > 0 && (gp= &term.line[*y-1][term.col-1])
                                        && gp->mode & ATTR_WRAP
                                        && !strchr(worddelimiters, gp->c[0])) {


> _AT_@ -720,8 +721,8 @@ selsnap(int mode, int *x, int *y, int direction) {
> }
> }
> if(direction > 0 && *x >= term.col-1) {
> - if(*y < term.row-1 && term.line[*y][*x].mode
> - & ATTR_WRAP) {
> + if(*y < term.row-1 && term.line[*y][*x].mode & ATTR_WRAP
> + && !strchr(worddelimiters, term.line[*y+1][0].c[0])) {

The same here.

Maybe the use of && to allow sequential code in a 'if' is not a good idea,
and maybe some refactoring could be done here to avoid so long lines and
the ugly sequential &&.

-- 
Roberto E. Vargas Caballero
Received on Wed Jun 04 2014 - 21:32:11 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 04 2014 - 21:36:06 CEST