|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
Un petit partage :)Voici un court code que je partage avec vous :) ..
il sagit d'un cgi permettant d'afficher avec colorisation un code gambas... bon bien sur ce n'est que l'application d'outils conçut pour ça dans gb3 C'est cour mais sympatique a observer :) comment l'utiliser ? dans une console en root: ln -s /usr/local/bin/gbr3 /usr/bin/gbr3 ln -s /usr/local/bin/gbx3 /usr/bin/gbr3 ln -s /usr/local/bin/gbs3 /usr/bin/gbw3 on installe apache server dans cgi-bin on copie le binaire généré avec l'ide (nommez le code.gambas)(généralement situé /usr/lib/cgi-bin ou /www/cgi-bin) puis avec un navigateur http://localhost/cgi-bin/code.gambas voila ... un premier cgi tourne sur votre machine Public Sub Main() Response.Begin Print "<Html>" Print "<head>" Print "<style type=\"text/css\">" Print ".keyword {color: 0080FF; font-weight: bold;}"; Print ".function {color: 0000FF; font-weight: normal;}"; Print ".operator {color: 0000FF; font-weight: bold;}"; Print ".symbol {color: 000000;}"; Print ".number {color: FF0000;}"; Print ".string {color: FF00FF;}"; Print ".comment {color: 808080;}"; Print ".datatype {color: 0080FF;}"; Print ".error {color:808000; font-style: italic;}" Print "div.code {OVERFLOW - Y: hidden; OVERFLOW - X: scroll; OVERFLOW: scroll; border: solid 1px #000; margin: 10px;} "; Print "div.code ul {list-style-type: decimal; font-family: \"monospace\"; font-size: 9pt; margin: 0px; padding: 0px; border-Left: solid 50px #fafafa;} "; Print "div.code ul li {padding - Left: 1em; padding-bottom: 2px; border-Left: solid 1px #dddddd; white-Space: pre;}"; Print "</style>" Print "</head><body>" GbToHtml(File.Load("Text1")) Response.End Print "</body></html>" End Public Sub GbToHtml(sValue As String) Dim Src, s As String Dim i As Integer Dim sTypes As String[] = ["", "normal", "keyword", "function", "operator", "symbol", "number", "string", "comment", "", "", "datatype"] Print "<div class=\"code\"><ul>" For Each s In Split(sValue, "\n") Highlight.Analyze(s) Print "<li>"; Try Print String(Highlight.Positions[0] * 2, " "); For i = 0 To Highlight.Symbols.Max Print Subst("<span class=\"&1\">&2</span>", sTypes[Highlight.Types[i]], Highlight.Symbols[i]); If i < Highlight.Symbols.Max Then If Highlight.Positions[i + 1] > Highlight.Positions[i] + Len(Highlight.Symbols[i]) Then Print " "; Endif Next Print "</li>" Next Print "</ul></div>" End ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Gambas-user-fr mailing list Gambas-user-fr@... https://lists.sourceforge.net/lists/listinfo/gambas-user-fr |
| Free embeddable forum powered by Nabble | Forum Help |