summaryrefslogtreecommitdiff
path: root/docview/components/richtext
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-12 09:11:57 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-02-03 15:33:43 +0200
commitfa8acc2b58592ea1382ae8a986c3c159e53229ce (patch)
treef6c0f34143d471ff11287fd6d3c1c1e500b6948a /docview/components/richtext
parent1e649f145f5a0930755b24756081f7399ab2847f (diff)
downloadfpGUI-fa8acc2b58592ea1382ae8a986c3c159e53229ce.tar.xz
temp storage for Encoding implementation in DocView
Diffstat (limited to 'docview/components/richtext')
-rw-r--r--docview/components/richtext/CanvasFontManager.pas72
-rw-r--r--docview/components/richtext/RichTextLayoutUnit.pas6
-rw-r--r--docview/components/richtext/RichTextView.pas45
3 files changed, 31 insertions, 92 deletions
diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas
index ed3abf08..063f759b 100644
--- a/docview/components/richtext/CanvasFontManager.pas
+++ b/docview/components/richtext/CanvasFontManager.pas
@@ -38,7 +38,6 @@ Type
{Standard Font character Set}
TFontCharSet=(fcsSBCS,fcsDBCS,fcsMBCS); {Single,Double,mixed Byte}
-
// a user-oriented specification of a font; not an actual structure in the INF file
TFontSpec = record
FaceName: string[ 64 ];
@@ -1070,70 +1069,17 @@ end;
procedure TCanvasFontManager.DrawString(var Point: TPoint; const Length: longint; const S: PChar);
var
- t: string;
-
- // Seaches <AValue> and replaces <ADel> with <AIns>. Case sensitive.
- function tiStrTran(AValue, ADel, AIns : string): string;
- var
- i : integer;
- sToChange : string;
- begin
- result := '';
- sToChange := AValue;
- i := UTF8Pos(ADel, sToChange);
- while i <> 0 do
- begin
- result := result + UTF8Copy(sToChange, 1, i-1) + AIns;
- UTF8Delete(sToChange, 1, i+UTF8length(ADel)-1);
- i := UTF8Pos(ADel, sToChange);
- end;
- result := result + sToChange;
- end;
-
+ t: TfpgString;
begin
t := s;
-
-// Hack Alert #2: replace strange table chars with something we can actually see
- //t := SubstituteChar(t, Chr(218), Char('+') ); // top-left corner
- //t := SubstituteChar(t, Chr(196), Char('-') ); // horz row deviders
- //t := SubstituteChar(t, Chr(194), Char('-') ); // centre top T connection
- //t := SubstituteChar(t, Chr(191), Char('+') ); // top-right corner
- //t := SubstituteChar(t, Chr(192), Char('+') ); // bot-left corner
- //t := SubstituteChar(t, Chr(193), Char('-') ); // centre bottom inverted T
- //t := SubstituteChar(t, Chr(197), Char('+') );
- //t := SubstituteChar(t, Chr(179), Char('|') ); //
- //t := SubstituteChar(t, Chr(195), Char('|') );
- //t := SubstituteChar(t, Chr(180), Char('|') );
- //t := SubstituteChar(t, Chr(217), Char('+') ); // bot-right corner
-
- // it's cheaper to first check for the char than actually running full tiStrTran
- // CodePage 437 (kind-of) to Unicode mapping
- t := tiStrTran(t, Char(16), '>' );
- t := tiStrTran(t, Char(17), '<' );
- t := tiStrTran(t, Char($1f), '▼' );
-// if pos(t, Char(179)) > 0 then
- t := tiStrTran(t, Char(179), '│' );
-// if pos(t, Char(180)) > 0 then
- t := tiStrTran(t, Char(180), '┤' );
-// if pos(t, Char(191)) > 0 then
- t := tiStrTran(t, Char(191), '┐' );
-// if pos(t, Char(192)) > 0 then
- t := tiStrTran(t, Char(192), '└' );
-// if pos(t, Char(193)) > 0 then
- t := tiStrTran(t, Char(193), '┴' );
-// if pos(t, Char(194)) > 0 then
- t := tiStrTran(t, Char(194), '┬' );
-// if pos(t, Char(195)) > 0 then
- t := tiStrTran(t, Char(195), '├' );
-// if pos(t, Char(196)) > 0 then
- t := tiStrTran(t, Char(196), '─' );
-// if pos(t, Char(197)) > 0 then
- t := tiStrTran(t, Char(197), '┼' );
-// if pos(t, Char(217)) > 0 then
- t := tiStrTran(t, Char(217), '┘' );
-// if pos(t, Char(218)) > 0 then
- t := tiStrTran(t, Char(218), '┌' );
-
+ //case Settings.Encoding of
+ // encUTF8: t := IPFToUTF8(t);
+ // encCP437: t := CP437ToUTF8(t);
+ // encCP850: t := CP850ToUTF8(t);
+ // encIBMGraph: t := IBMGraphToUTF8(t);
+ //else
+ // t := IPFToUTF8(t);
+ //end;
FCanvas.DrawString(Point.X, Point.Y, t);
Point.x := Point.X + Canvas.Font.TextWidth(t);
end;
diff --git a/docview/components/richtext/RichTextLayoutUnit.pas b/docview/components/richtext/RichTextLayoutUnit.pas
index 9b684349..61ce150c 100644
--- a/docview/components/richtext/RichTextLayoutUnit.pas
+++ b/docview/components/richtext/RichTextLayoutUnit.pas
@@ -437,7 +437,7 @@ ProfileEvent('DEBUG: TRichTextLayout.Layout >>>>');
if not FFontManager.IsFixed then
begin
// end of italic; add a space
- inc( WordX, FFontManager.CharWidth( ' ' ) );
+// inc( WordX, FFontManager.CharWidth( ' ' ) );
end;
end;
@@ -706,7 +706,7 @@ begin
and ( faItalic in Style.Font.Attributes )
and ( not FFontManager.IsFixed ) then
// end of italic; add a space
- inc( X, FFontManager.CharWidth( ' ' ) );
+// inc( X, FFontManager.CharWidth( ' ' ) );
PerformStyleTag( Element.Tag,
Style,
@@ -783,7 +783,7 @@ begin
and ( faItalic in Style.Font.Attributes )
and ( not FFontManager.IsFixed ) then
// end of italic; add a space
- inc( X, FFontManager.CharWidth( ' ' ) );
+// inc( X, FFontManager.CharWidth( ' ' ) );
PerformStyleTag( Element.Tag,
Style,
diff --git a/docview/components/richtext/RichTextView.pas b/docview/components/richtext/RichTextView.pas
index e32c71ee..5e518d78 100644
--- a/docview/components/richtext/RichTextView.pas
+++ b/docview/components/richtext/RichTextView.pas
@@ -41,6 +41,9 @@ Type
TScrollingDirection = ( sdUp, sdDown );
+var
+ testvar: integer = 0;
+
Type
TRichTextView = class;
@@ -408,6 +411,8 @@ uses
,nvUtilities
,RichTextDocumentUnit
,RichTextDisplayUnit
+ ,fpg_stringutils
+ ,SettingsUnit // TODO: We shouldn't have this dependency!!
;
Procedure TRichTextView.SetSelectionStart( SelectionStart: longint );
@@ -503,7 +508,6 @@ var
StartLine: longint;
EndLine: longint;
begin
-
if SelectionSet then
begin
OldClip := Canvas.GetClipRect;
@@ -768,9 +772,10 @@ var
begin
inherited HandleLMouseDown(x, y, shiftstate);
Offset := 0;
+ testvar := 1;
Position := FindPoint( X, Y, Line, Offset, Link );
FClickedLink := Link;
-// writeln('Pos=', Ord(Position), ' link=', Link);
+ writeln(' link=', Link, ' line=', Line, ' offset=', offset);
if Position in [tpAboveTextArea, tpBelowTextArea] then
// not on the control (this probably won't happen)
@@ -1100,6 +1105,9 @@ function TRichTextView.FindPoint( XToFind: longint;
var
TextHeight: longint;
begin
+ if testvar = 1 then
+ testvar := 0;
+
LineIndex := 0;
Offset := 0;
Link := '';
@@ -1642,31 +1650,8 @@ end;
// ADelay = True means that we hold off on redoing the Layout and Painting.
Procedure TRichTextView.AddText( Text: PChar; ADelay: boolean );
-var
- s: string;
begin
- s := Text;
- // Warning: Hack Alert! replace some strange Bell character found in some INF files
-// s := SubstituteChar(s, Chr($07), Chr($20) );
- s := StringReplace(s, Chr($07), #$E2#$80#$A2, [rfReplaceAll, rfIgnoreCase]); // u+2022 small bullet
-
-//// Hack Alert #2: replace strange table chars with something we can actually see
-// s := SubstituteChar(s, Chr(218), Char('+') ); // top-left corner
-// s := SubstituteChar(s, Chr(196), Char('-') ); // horz row deviders
-// s := SubstituteChar(s, Chr(194), Char('-') ); // centre top T connection
-// s := SubstituteChar(s, Chr(191), Char('+') ); // top-right corner
-// s := SubstituteChar(s, Chr(192), Char('+') ); // bot-left corner
-// s := SubstituteChar(s, Chr(193), Char('-') ); // centre bottom inverted T
-// s := SubstituteChar(s, Chr(197), Char('+') );
-// s := SubstituteChar(s, Chr(179), Char('|') ); //
-// s := SubstituteChar(s, Chr(195), Char('|') );
-// s := SubstituteChar(s, Chr(180), Char('|') );
-// s := SubstituteChar(s, Chr(217), Char('+') ); // bot-right corner
-
-
-
-
- AddAndResize( FText, PChar(s) );
+ AddAndResize( FText, Text);
if not ADelay then
begin
Layout;
@@ -2110,6 +2095,9 @@ begin
FCursorOffset := Offset;
FCursorRow := Row;
Index := FLayout.GetCharIndex( FLayout.FLines^[ Row ].Text ) + Offset;
+
+ writeln(' SetCursorPosition: offset=', FCursorOffset, ' row=', FCursorRow, ' index=', Index);
+ exit;
if PreserveSelection then
begin
SetSelectionEndInternal( Index )
@@ -2790,6 +2778,11 @@ begin
end
else
begin
+ writeln('need to scroll down, desired row below bottom line');
+ writeln('BottomLine = ', BottomLine, ' Row = ', Row);
+ writeln('new pos = ', FLayout.GetLinePosition( Row )
+ + FLayout.FLines^[ Row ].Height
+ - GetTextAreaHeight);
// need to scroll down, desired row below bottom line
if ( BottomLine <> -1 )
and ( Row >= BottomLine ) then