|
From: | Sahitihi |
Subject: | Re: Fwd: Re: Patch file for colorize module |
Date: | Sun, 3 Jun 2018 19:48:42 +0530 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
Hi Ricardo, I have worked with different possibilities String-prefix resulted a boolean output so, I thought of using conditionals.Now all you need to do is work on the “handle-string” procedure. I suggest using simpler matching procedures at first. To get started try “string-prefix?” and use it with the string “starting phase”. This won’t work with regular expressions, though. Following is the line I added to “handle-string” procedure (if (string-prefix? "starting phase" str) (colorized-display str '(GREEN)) (display str target-port) )) While you *can* use “regexp-substitute/global”, I don’t think it’s a good fit here, because we may want to extend the string matching features, which is difficult to do with “regexp-substitute/global”. Instead, try to match regular expressions one by one with “string-match” and then operate on the match structure it returns. If it returns #f you can move on to the next _expression_. If none match you just return the original string. If one matches you *rebuild* the string, but with colours applied. Do I need to write multiple definitions for each _expression_? '("^starting phase.*" "^phase .* succeeded.*" "^phase .* failed.*") If you don’t understand this example please look up the procedures in the Guile manual. I dint find this example in procedures, may I overlooked somewhere I recheck it. Thanks! Sahithi |
[Prev in Thread] | Current Thread | [Next in Thread] |