Rev 18 | Rev 23 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 18 | Rev 22 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | function LoadFileToStr(const FileName: TFileName): AnsiString; |
11 | function LoadFileToStr(const FileName: TFileName): AnsiString; |
12 | function LastPos(const SubStr, S: string): integer; |
12 | function LastPos(const SubStr, S: string): integer; |
13 | function IsTextHTML(s: string): boolean; |
13 | function IsTextHTML(s: string): boolean; |
14 | function GetWordUnderCaret(AMemo: TSynEdit): string; |
14 | function GetWordUnderCaret(AMemo: TSynEdit): string; |
15 | function MyVarToStr(v: Variant): string; |
15 | function MyVarToStr(v: Variant): string; |
- | 16 | function FileSystemCaseSensitive: boolean; |
|
16 | 17 | ||
17 | implementation |
18 | implementation |
18 | 19 | ||
19 | function GetDosOutput(CommandLine: string; Work: string = ''): string; |
20 | function GetDosOutput(CommandLine: string; Work: string = ''): string; |
20 | var |
21 | var |
Line 127... | Line 128... | ||
127 | if (StrIPos('</'+tag+'>', s) > 0) then Inc(result); |
128 | if (StrIPos('</'+tag+'>', s) > 0) then Inc(result); |
128 | if (StrIPos('<'+tag+' />', s) > 0) then Inc(result); |
129 | if (StrIPos('<'+tag+' />', s) > 0) then Inc(result); |
129 | if (StrIPos('<'+tag+' ', s) > 0) then Inc(result); |
130 | if (StrIPos('<'+tag+' ', s) > 0) then Inc(result); |
130 | end; |
131 | end; |
131 | 132 | ||
- | 133 | procedure _Check(const tag: string; pair: boolean); |
|
132 | var |
134 | begin |
- | 135 | if (pair and (_Tag(tag) >= 2)) or (not pair and (_Tag(tag) >= 1)) then result := true; |
|
133 | score: integer; |
136 | end; |
- | 137 | ||
134 | begin |
138 | begin |
- | 139 | result := false; |
|
- | 140 | _Check('html', true); |
|
- | 141 | _Check('body', true); |
|
135 | score := _Tag('html') + _Tag('body') + _Tag('p') + _Tag('a') + _Tag('b') + |
142 | _Check('p', false{end tag optional}); |
- | 143 | _Check('a', true); |
|
- | 144 | _Check('b', true); |
|
- | 145 | _Check('i', true); |
|
- | 146 | _Check('u', true); |
|
136 | _Tag('i') + _Tag('u') + _Tag('li') + _Tag('ol') + _Tag('ul') + |
147 | _Check('li', false{end tag optional}); |
- | 148 | _Check('ol', true); |
|
- | 149 | _Check('ul', true); |
|
- | 150 | _Check('img', false); |
|
137 | _Tag('img') + _Tag('div') + _Tag('hr') + _Tag('code') + |
151 | _Check('div', false); |
- | 152 | _Check('hr', false); |
|
- | 153 | _Check('code', true); |
|
- | 154 | _Check('pre', true); |
|
138 | _Tag('pre') + _Tag('blockquote') + _Tag('span') + _Tag('br'); |
155 | _Check('blockquote', true); |
139 | result := score >= 2; |
156 | _Check('span', true); |
- | 157 | _Check('br', false); |
|
140 | end; |
158 | end; |
141 | 159 | ||
142 | // Template: http://stackoverflow.com/questions/6339446/delphi-get-the-whole-word-where-the-caret-is-in-a-memo |
160 | // Template: http://stackoverflow.com/questions/6339446/delphi-get-the-whole-word-where-the-caret-is-in-a-memo |
143 | function GetWordUnderCaret(AMemo: TSynEdit): string; |
161 | function GetWordUnderCaret(AMemo: TSynEdit): string; |
144 | 162 | ||
Line 215... | Line 233... | ||
215 | // At least try it... |
233 | // At least try it... |
216 | result := VarToStr(v); |
234 | result := VarToStr(v); |
217 | end; |
235 | end; |
218 | end; |
236 | end; |
219 | 237 | ||
- | 238 | function FileSystemCaseSensitive: boolean; |
|
- | 239 | begin |
|
- | 240 | // TODO: This code is not very reliable. At MAC OSX, the file system HFS can be switched |
|
- | 241 | // between case sensitivity and insensitivity. |
|
- | 242 | {$IFDEF LINUX} |
|
- | 243 | exit(true); |
|
- | 244 | {$ELSE} |
|
- | 245 | exit(false); |
|
- | 246 | {$ENDIF} |
|
- | 247 | end; |
|
- | 248 | ||
220 | end. |
249 | end. |