mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-15 20:49:17 +02:00
* updates for cursor setting
* button press event works
This commit is contained in:
parent
c3a92e5260
commit
9de2afcbac
@ -64,7 +64,7 @@ begin
|
|||||||
e.shSymbol := AddSHStyle('Symbol', colBrown, colDefault, fsNormal);
|
e.shSymbol := AddSHStyle('Symbol', colBrown, colDefault, fsNormal);
|
||||||
e.shKeyword := AddSHStyle('Keyword', colBlack, colDefault, fsBold);
|
e.shKeyword := AddSHStyle('Keyword', colBlack, colDefault, fsBold);
|
||||||
e.shComment := AddSHStyle('Comment', colDarkCyan, colDefault, fsItalics);
|
e.shComment := AddSHStyle('Comment', colDarkCyan, colDefault, fsItalics);
|
||||||
e.shDirective := AddSHStyle('Directive', colDarkYellow, colDefault, fsItalics);
|
e.shDirective := AddSHStyle('Directive', colRed, colDefault, fsItalics);
|
||||||
e.shNumbers := AddSHStyle('Numbers', colDarkMagenta, colDefault, fsNormal);
|
e.shNumbers := AddSHStyle('Numbers', colDarkMagenta, colDefault, fsNormal);
|
||||||
e.shCharacters := AddSHStyle('Characters', colDarkBlue, colDefault, fsNormal);
|
e.shCharacters := AddSHStyle('Characters', colDarkBlue, colDefault, fsNormal);
|
||||||
e.shStrings := AddSHStyle('Strings', colBlue, colDefault, fsNormal);
|
e.shStrings := AddSHStyle('Strings', colBlue, colDefault, fsNormal);
|
||||||
@ -135,7 +135,11 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.5 1999-12-08 01:03:15 peter
|
Revision 1.6 1999-12-22 22:28:08 peter
|
||||||
|
* updates for cursor setting
|
||||||
|
* button press event works
|
||||||
|
|
||||||
|
Revision 1.5 1999/12/08 01:03:15 peter
|
||||||
* changes so redrawing and walking with the cursor finally works
|
* changes so redrawing and walking with the cursor finally works
|
||||||
correct
|
correct
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ begin
|
|||||||
|
|
||||||
edit.GdkWnd := edit.PaintBox^.window;
|
edit.GdkWnd := edit.PaintBox^.window;
|
||||||
edit.GC := gdk_gc_new(edit.GdkWnd);
|
edit.GC := gdk_gc_new(edit.GdkWnd);
|
||||||
edit.CurGCColor := 0; // Reset color, because we have a new GC!
|
edit.CurGCColor := 0; // Reset color, because we have a new GC!
|
||||||
gdk_gc_copy(edit.GC, PGtkStyle(edit.PaintBox^.thestyle)^.
|
gdk_gc_copy(edit.GC, PGtkStyle(edit.PaintBox^.thestyle)^.
|
||||||
fg_gc[edit.PaintBox^.state]);
|
fg_gc[edit.PaintBox^.state]);
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ begin
|
|||||||
GDK_Shift_L..GDK_Hyper_R :
|
GDK_Shift_L..GDK_Hyper_R :
|
||||||
begin
|
begin
|
||||||
// Don't let modifier keys trough as normal keys
|
// Don't let modifier keys trough as normal keys
|
||||||
// *** This doesn't work reliably! (sg)
|
// *** This doesn't work reliably! (sg)
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
@ -190,7 +190,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
KeyState:=Event^.State;
|
KeyState:=Event^.State;
|
||||||
|
|
||||||
// WriteLn('KeyCode ', KeyCode,' keystate ',KeyState);
|
WriteLn('KeyCode ', KeyCode,' keystate ',KeyState);
|
||||||
|
|
||||||
// Calculate the Key modifiers (shiftstate)
|
// Calculate the Key modifiers (shiftstate)
|
||||||
KeyMods := [];
|
KeyMods := [];
|
||||||
@ -211,8 +211,15 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
function TGtkSHEdit_ButtonPressEvent(GtkWidget: PGtkWidget; event: PGdkEventButton ; edit: TGtkSHEdit): Integer; cdecl;
|
function TGtkSHEdit_ButtonPressEvent(GtkWidget: PGtkWidget; event: PGdkEventButton ; edit: TGtkSHEdit): Integer; cdecl;
|
||||||
|
var
|
||||||
|
px,py : integer;
|
||||||
begin
|
begin
|
||||||
Writeln('button press');
|
px:=(round(event^.x)-edit.leftindent) div edit.CharW;
|
||||||
|
py:=(round(event^.y)-edit.leftindent) div edit.CharH;
|
||||||
|
// Writeln('button press ',px,',',py);
|
||||||
|
edit.Edit.CursorX:=px;
|
||||||
|
edit.Edit.CursorY:=py;
|
||||||
|
edit.SetFocus;
|
||||||
Result := 1;
|
Result := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -273,18 +280,23 @@ begin
|
|||||||
gtk_scrolled_window_add_with_viewport(PGtkScrolledWindow(Widget), PaintBox);
|
gtk_scrolled_window_add_with_viewport(PGtkScrolledWindow(Widget), PaintBox);
|
||||||
gtk_widget_show(PaintBox);
|
gtk_widget_show(PaintBox);
|
||||||
|
|
||||||
PGtkObject(PaintBox)^.flags := PGtkObject(PaintBox)^.flags or GTK_CAN_FOCUS;
|
gtk_widget_set_flags(PGtkWidget(PaintBox),GTK_CAN_FOCUS);
|
||||||
|
|
||||||
gtk_signal_connect(PGtkObject(PaintBox), 'expose-event',
|
gtk_signal_connect(PGtkObject(PaintBox), 'expose-event',
|
||||||
GTK_SIGNAL_FUNC(@TGtkSHEdit_Expose), self);
|
GTK_SIGNAL_FUNC(@TGtkSHEdit_Expose), self);
|
||||||
gtk_signal_connect_after(PGtkObject(PaintBox), 'key-press-event',
|
gtk_signal_connect_after(PGtkObject(PaintBox), 'key-press-event',
|
||||||
GTK_SIGNAL_FUNC(@TGtkSHEdit_KeyPressed), self);
|
GTK_SIGNAL_FUNC(@TGtkSHEdit_Keypressed), self);
|
||||||
gtk_signal_connect_after(PGtkObject(PaintBox), 'button-press-event',
|
gtk_signal_connect(PGtkObject(PaintBox), 'button-press-event',
|
||||||
GTK_SIGNAL_FUNC(@TGtkSHEdit_KeyPressed), self);
|
GTK_SIGNAL_FUNC(@TGtkSHEdit_ButtonPressEvent), self);
|
||||||
gtk_signal_connect_after(PGtkObject(PaintBox), 'focus-in-event',
|
gtk_signal_connect_after(PGtkObject(PaintBox), 'focus-in-event',
|
||||||
GTK_SIGNAL_FUNC(@TGtkSHEdit_FocusInEvent), self);
|
GTK_SIGNAL_FUNC(@TGtkSHEdit_FocusInEvent), self);
|
||||||
gtk_signal_connect_after(PGtkObject(PaintBox), 'focus-out-event',
|
gtk_signal_connect_after(PGtkObject(PaintBox), 'focus-out-event',
|
||||||
GTK_SIGNAL_FUNC(@TGtkSHEdit_FocusOutEvent), self);
|
GTK_SIGNAL_FUNC(@TGtkSHEdit_FocusOutEvent), self);
|
||||||
|
|
||||||
|
gtk_widget_set_events(PGtkWidget(Paintbox),
|
||||||
|
GDK_EXPOSURE_MASK or GDK_KEY_PRESS_MASK or GDK_KEY_RELEASE_MASK or
|
||||||
|
GDK_BUTTON_PRESS_MASK or GDK_ENTER_NOTIFY_MASK or GDK_LEAVE_NOTIFY_MASK);
|
||||||
|
|
||||||
gtk_widget_show(Widget);
|
gtk_widget_show(Widget);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -292,9 +304,9 @@ end;
|
|||||||
procedure TGtkSHEdit.SetEdit(AEdit: TSHTextEdit);
|
procedure TGtkSHEdit.SetEdit(AEdit: TSHTextEdit);
|
||||||
begin
|
begin
|
||||||
Edit := AEdit;
|
Edit := AEdit;
|
||||||
shWhitespace := AddSHStyle('Whitespace', colBlack, colWhite, fsNormal);
|
shWhitespace := AddSHStyle('Whitespace', colBlack, colWhite, fsNormal);
|
||||||
Edit.shDefault := AddSHStyle('Default', colBlack, colWhite, fsNormal);
|
Edit.shDefault := AddSHStyle('Default', colBlack, colWhite, fsNormal);
|
||||||
Edit.shSelected := AddSHStyle('Selected', colWhite, colBlue, fsNormal);
|
Edit.shSelected := AddSHStyle('Selected', colWhite, colDarkBlue, fsNormal);
|
||||||
{ Install keys }
|
{ Install keys }
|
||||||
Edit.AddKeyDef(@Edit.CursorUp, selClear, 'Cursor up', GDK_Up, []);
|
Edit.AddKeyDef(@Edit.CursorUp, selClear, 'Cursor up', GDK_Up, []);
|
||||||
Edit.AddKeyDef(@Edit.CursorDown, selClear, 'Cursor down', GDK_Down, []);
|
Edit.AddKeyDef(@Edit.CursorDown, selClear, 'Cursor down', GDK_Down, []);
|
||||||
@ -320,8 +332,9 @@ begin
|
|||||||
|
|
||||||
Edit.AddKeyDef(@Edit.ToggleOverwriteMode, selNothing, 'Toggle overwrite mode', GDK_Insert, []);
|
Edit.AddKeyDef(@Edit.ToggleOverwriteMode, selNothing, 'Toggle overwrite mode', GDK_Insert, []);
|
||||||
Edit.AddKeyDef(@Edit.EditDelLeft, selClear, 'Delete char left of cursor', GDK_Backspace, []);
|
Edit.AddKeyDef(@Edit.EditDelLeft, selClear, 'Delete char left of cursor', GDK_Backspace, []);
|
||||||
Edit.AddKeyDef(@Edit.EditDelRight, selClear, 'Delete char right of cursor', GDK_Delete, []);
|
Edit.AddKeyDef(@Edit.EditDelRight, selClear, 'Delete char right of cursor', GDK_Delete_Key, []);
|
||||||
Edit.AddKeyDef(@Edit.EditDelLine, selClear, 'Delete current line', Ord('Y'), [ssCtrl]);
|
Edit.AddKeyDef(@Edit.EditDelLine, selClear, 'Delete current line', Ord('Y'), [ssCtrl]);
|
||||||
|
Edit.AddKeyDef(@Edit.EditDelLine, selClear, 'Delete current line', Ord('y'), [ssCtrl]);
|
||||||
Edit.AddKeyDef(@Edit.EditUndo, selClear, 'Undo last action', GDK_Backspace, [ssAlt]);
|
Edit.AddKeyDef(@Edit.EditUndo, selClear, 'Undo last action', GDK_Backspace, [ssAlt]);
|
||||||
Edit.AddKeyDef(@Edit.EditRedo, selClear, 'Redo last undone action', GDK_Backspace, [ssShift, ssAlt]);
|
Edit.AddKeyDef(@Edit.EditRedo, selClear, 'Redo last undone action', GDK_Backspace, [ssShift, ssAlt]);
|
||||||
end;
|
end;
|
||||||
@ -466,8 +479,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
' ': begin
|
' ': begin
|
||||||
Inc(s);
|
Inc(s);
|
||||||
Inc(CurX1);
|
Inc(CurX1);
|
||||||
end;
|
end;
|
||||||
else begin
|
else begin
|
||||||
if (CurX1 >= x1) and (CurX1 <= x2) then begin
|
if (CurX1 >= x1) and (CurX1 <= x2) then begin
|
||||||
SetGCColor(SHStyles^[RequestedColor].Color);
|
SetGCColor(SHStyles^[RequestedColor].Color);
|
||||||
@ -582,7 +595,11 @@ end;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.7 1999-12-12 17:50:50 sg
|
Revision 1.8 1999-12-22 22:28:08 peter
|
||||||
|
* updates for cursor setting
|
||||||
|
* button press event works
|
||||||
|
|
||||||
|
Revision 1.7 1999/12/12 17:50:50 sg
|
||||||
* Fixed drawing of selection
|
* Fixed drawing of selection
|
||||||
* Several small corrections (removed superfluous local variables etc.)
|
* Several small corrections (removed superfluous local variables etc.)
|
||||||
|
|
||||||
|
@ -260,7 +260,6 @@ type
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -372,15 +371,15 @@ end;
|
|||||||
|
|
||||||
procedure TSHTextEdit.SetCursorX(NewCursorX: Integer);
|
procedure TSHTextEdit.SetCursorX(NewCursorX: Integer);
|
||||||
begin
|
begin
|
||||||
FCursorX := NewCursorX;
|
|
||||||
HideCursor;
|
HideCursor;
|
||||||
|
FCursorX := NewCursorX;
|
||||||
ShowCursor;
|
ShowCursor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSHTextEdit.SetCursorY(NewCursorY: Integer);
|
procedure TSHTextEdit.SetCursorY(NewCursorY: Integer);
|
||||||
begin
|
begin
|
||||||
FCursorY := NewCursorY;
|
|
||||||
HideCursor;
|
HideCursor;
|
||||||
|
FCursorY := NewCursorY;
|
||||||
ShowCursor;
|
ShowCursor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -402,7 +401,11 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.5 1999-12-10 15:01:03 peter
|
Revision 1.6 1999-12-22 22:28:09 peter
|
||||||
|
* updates for cursor setting
|
||||||
|
* button press event works
|
||||||
|
|
||||||
|
Revision 1.5 1999/12/10 15:01:03 peter
|
||||||
* first things for selection
|
* first things for selection
|
||||||
* Better Adjusting of range/cursor
|
* Better Adjusting of range/cursor
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user