Mercurial > repos > rhope
view countstring.rhope @ 164:429afd920a23
Allow sending and receiving arrays of arbitrary objects rather than just UInt8s
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 10 Jan 2011 00:25:35 -0500 |
parents | 0a4682be2db2 |
children |
line wrap: on
line source
Blueprint Count String { Text Line Column } Count String[text:out] { out <- Count String At Pos[text, 0, 0] } Count String At Pos[text,line,col:out] { out <- [[[Build[Count String()]]Text <<[text]]Line <<[line]]Column <<[col] } Slice@Count String[string,index:left,right] { If[[index] = [0]] { left <- [string]Text <<[""] right <- Val[string] }{ ltext,rtext <- [[string]Text >>]Slice[index] left <- [string]Text <<[ltext] parts <- [ltext]Split["\n"] last line <- [[parts]Length] - [1] rline <- [[string]Line >>] + [last line] prercol <- [[parts]Index[last line]]Length If[[last line] > [0]] { rcol <- Val[prercol] }{ rcol <- [prercol] + [[string]Column >>] } right <- Count String At Pos[rtext, rline, rcol] } } Length@Count String[string:out] { out <- Length[[string]Text >>] } Byte Length@Count String[string:out] { out <- Byte Length[[string]Text >>] } Byte@Count String[string,index:out,invalid] { out,invalid <- Byte[[string]Text >>, index] } Append@Count String[left,right:out] { If[[[left]Length] > [0]] { out <- [left]Text << [ [String[left]]Append[String[right]] ] }{ out <- right } } =@Count String[left,right:out] { out <- [String[left]] = [String[right]] } _Slice=@Count String[left,right:out] { out <- _Slice=[String[left], String[right]] } _Flat=@Count String[left,right:out] { out <- _Flat=[String[left], String[right]] } _Flatten@Count String[string,dest,offset,count:out] { out <- _Flatten[[string]Text >>, dest, offset, count] } /*Partition@Count String[string, delims:before,delim,after,nomatch] { ,delim,,nomatch <- [[string]Text >>]Partition[delims] { before <- [string]Text <<[~] bparts <- [~]Split["\n"] preblines <- [[bparts]Length] - [1] If[[preblines] > [-1]] { blines <- Val[preblines] bcols <- Length[[bparts]Index[blines]] }{ bcols <- 0 blines <- 0 } }{ dparts <- [~]Split["\n"] dlines <- [[dparts]Length]-[1] dcols <- Length[[dparts]Index[dlines]] }{ If[[dlines] > [0]] { cols <- Val[dcols] }{ If[[blines] > [0]] { cols <- [bcols] + [dcols] }{ cols <- [[bcols] + [dcols]] + [[string]Column >>] } } after <- Count String At Pos[~, [[blines]+[dlines]] + [[string]Line >>], cols] } }*/ String@Count String[string:out] { out <- [string]Text >> } Empty@Count String[string:out] { out <- Count String[""] }