Sorry for all the "free code", but the last two commands should do what you want. This may or may not handle tabs correctly -- I dont use tabs so, probably not. Also my typical indent is 2 chars in case you have to tweak this code. (and yes, I know there is an easier way to do this but my brain isnt in gear at the moment)
_str at_line_left_str(int offset=0)
{
get_line(line);
l=substr(line,1,offset+p_col-1);
return l;
}
boolean valid_line(int l0)
{
if (l0<1||p_Noflines<l0) {
return false;
}
return true;
}
int at_line_text(_str &text,int offset=0,int line=p_line)
{
if (!valid_line(line+offset)) {return (-1);}
save_pos(p);
p_line=line+offset;
get_line(text);
restore_pos(p);
return 0;
}
boolean at_line_flag(int offset=0,int line=p_line,int flag=0)
{
if (valid_line(line+offset)==false) {
return false;
}
save_pos(p);
p_line=line+offset;
l=_lineflags();
restore_pos(p);
return (l&flag);
}
boolean at_line_minus(int offset=0,int line=p_line)
{
return at_line_flag(offset,line,MINUSBITMAP_LF);
}
boolean at_line_hid(int offset=0,int line=p_line)
{
return at_line_flag(offset,line,HIDDEN_LF);
}
boolean xt_seek_compare(int i1,int i2,_str op='==')
{
if (op=='==') {return (i1==i2);}
if (op=='!=') {return (i1!=i2);}
if (op=='<') {return (i1<i2);}
if (op=='>') {return (i1>i2);}
if (op=='>=') {return (i1>=i2);}
if (op=='<=') {return (i1<=i2);}
//if (op=='<>') {return (i1<i2||);}
return false;
}
int at_line_indent(int offset,int line=p_line)
{
status=at_line_text(text,offset,line);
if (status) {return (-1);}
t1=strip(text,"L"," ");
v1=length(text)-length(t1);
t2=strip(text,"L","\t");
v2=length(text)-length(t2);
return (v1+(v2*2));
}
boolean at_line_plus(int offset=0,int line=p_line)
{
return at_line_flag(offset,line,PLUSBITMAP_LF);
}
int xt_seek_indents(int prev=0,int plus=0,int indent=-1,_str comp='==',int hid=0,int l=p_line,boolean ib=false)
{
ol=l;
//if (indent=-1) {indent=at_line_indent(0,l);}
//if (indent=-1) {return (-1);}
while (true) {
if (prev==0) {l++;}else{l--;}
if (!valid_line(l)) {return (-1);}
//get_line(ln);
//at_line_text(_str &text,int offset=0,int line=p_line)
at_line_text(ln,0,l);
//Msg('"'ln'"');
if (ib&&ln=='') {
}else{
if (plus==0) {
if (at_line_minus(0,l)) {
if (hid==0) {
if (!at_line_hid(0,l)) {
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}else if (hid==1) {
if (at_line_hid(0,l)) {
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}else{
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}
}else if (plus==1) {
if (at_line_plus(0,l)) {
if (hid==0) {
if (!at_line_hid(0,l)) {
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}else if (hid==1) {
if (at_line_hid(0,l)) {
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}else{
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}
}else{
if (hid==0) {
if (!at_line_hid(0,l)) {
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}else if (hid==1) {
if (at_line_hid(0,l)) {
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}else{
if (indent!=-1) {
if (xt_seek_compare(at_line_indent(0,l),indent,comp)) {
return l;
}
}else{
return l;
}
}
}
}
}
return (-1);
}
_command void curs_seek_up_indent_same() name_info(','VSARG2_LASTKEY|VSARG2_CMDLINE|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
//curs_seek_up_indent_same is not bound to a key
{
//Msg(p_col);
//int xt_seek_indents(
// int prev=0,
// int plus=0,
// int indent=-1,
// _str comp='==',
// int hid=0,
// int l=p_line
// )
save_pos(p);
ll=at_line_left_str();ll=length(ll);
restore_pos(p);
int i=xt_seek_indents(1,-1,ll);
//Msg(i);
if (i>1) {
goto_line(i);
}
}
_command void curs_seek_down_indent_same() name_info(','VSARG2_LASTKEY|VSARG2_CMDLINE|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
//Msg(p_col);
//int xt_seek_indents(
// int prev=0,
// int plus=0,
// int indent=-1,
// _str comp='==',
// int hid=0,
// int l=p_line
// )
save_pos(p);
ll=at_line_left_str();ll=length(ll);
restore_pos(p);
int i=xt_seek_indents(0,-1,ll);
//Msg(i);
if (i>1) {
goto_line(i);
}
}