mirror of
https://git.code.sf.net/p/fldigi/flmsg
synced 2026-08-13 17:30:58 -04:00
fltk-1.3 mods
* changes to support conditional compilation against fltk-1.3.x
This commit is contained in:
parent
5796660c71
commit
cd790b5f86
54 changed files with 4942 additions and 4506 deletions
|
|
@ -115,8 +115,6 @@ SectionEnd
|
|||
Section "Start Menu Shortcuts"
|
||||
CreateDirectory "${SM_PATH}"
|
||||
CreateShortCut "${SM_PATH}\${FLMSG_NAME}.lnk" "$INSTDIR\${FLMSG_BINARY}" "" "$INSTDIR\${FLMSG_BINARY}" 0
|
||||
CreateShortCut "${SM_PATH}\${FLMSG_NAME} Beginners' Guide.lnk" "${GUIDE_URL}"
|
||||
CreateShortCut "${SM_PATH}\${FLMSG_NAME} Documentation.lnk" "${FLMSG_DOCS_URL}"
|
||||
CreateShortCut "${SM_PATH}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
|
||||
SectionEnd
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ AC_DEFUN([AC_CHECK_FLTK], [
|
|||
if test "x$FLTK_API_VERSION" = "x1.1" || test "x$FLTK_API_VERSION" = "x1.2" || test "x$FLTK_API_VERSION" = "x1.3"; then
|
||||
HAVE_FLTK_API_VERSION=yes
|
||||
fi
|
||||
FLMSG_FLTK_API_MAJOR=${FLTK_API_VERSION%%.*}
|
||||
FLMSG_FLTK_API_MINOR=${FLTK_API_VERSION#*.}; FLMSG_FLTK_API_MINOR=${FLMSG_FLTK_API_MINOR%%.*}
|
||||
if test "${HAVE_FLTK_API_VERSION}" = "no"; then
|
||||
AC_MSG_ERROR([
|
||||
*** The version of FLTK found on your system provides API version $FLTK_API_VERSION.
|
||||
|
|
@ -43,6 +45,8 @@ AC_DEFUN([AC_CHECK_FLTK], [
|
|||
AC_SUBST([FLTK_CFLAGS])
|
||||
AC_SUBST([FLTK_LIBS])
|
||||
AC_DEFINE_UNQUOTED([FLTK_BUILD_VERSION], ["`$FLTK_CONFIG --version`"], [FLTK version])
|
||||
AC_DEFINE_UNQUOTED([FLMSG_FLTK_API_MAJOR], [$FLMSG_FLTK_API_MAJOR], [FLTK API major version])
|
||||
AC_DEFINE_UNQUOTED([FLMSG_FLTK_API_MINOR], [$FLMSG_FLTK_API_MINOR], [FLTK API minor version])
|
||||
|
||||
AC_ARG_VAR([FLUID], [Fast Light User-Interface Designer])
|
||||
AC_CHECK_PROG([FLUID], [fluid], [fluid])
|
||||
|
|
|
|||
|
|
@ -37,5 +37,42 @@ set -e
|
|||
test "x$NOSTRIP" = "x" && $STRIP -S "$flmsg_bin"
|
||||
def="$def -Dflmsg_NAME=$flmsg_name -Dflmsg_BINARY=$flmsg_bin -Dflmsg_VERSION=$PACKAGE_VERSION"
|
||||
|
||||
# Look for pthreadGC2.dll and mingwm10.dll
|
||||
MINGWM_DLL=mingwm10.dll
|
||||
PTW32_DLL=pthreadGC2.dll
|
||||
if ! test -r "$build/$MINGWM_DLL" || ! test -r "$build/$PTW32_DLL"; then
|
||||
IFS_saved="$IFS"
|
||||
IFS=:
|
||||
MINGWM_PATH=""
|
||||
PTW32_PATH=""
|
||||
for dir in $LIB_PATH; do
|
||||
test "x$MINGWM_PATH" = "x" && test -r "$dir/$MINGWM_DLL" && MINGWM_PATH="$dir/$MINGWM_DLL"
|
||||
test "x$PTW32_PATH" = "x" && test -r "$dir/$PTW32_DLL" && PTW32_PATH="$dir/$PTW32_DLL"
|
||||
done
|
||||
IFS="$IFS_saved"
|
||||
fi
|
||||
if ! test -r "$build/$MINGWM_DLL"; then
|
||||
if test "x$MINGWM_PATH" != "x"; then
|
||||
cp "$MINGWM_PATH" "$build"
|
||||
elif test -r /usr/share/doc/mingw32-runtime/${MINGWM_DLL}.gz; then
|
||||
# Debian and Ubuntu
|
||||
gzip -dc /usr/share/doc/mingw32-runtime/${MINGWM_DLL}.gz > "$build/$MINGWM_DLL"
|
||||
fi
|
||||
fi
|
||||
if ! test -r "$build/$PTW32_DLL"; then
|
||||
if test "x$PTW32_PATH" != "x"; then
|
||||
cp "$PTW32_PATH" "$build"
|
||||
else
|
||||
# look for dll in PTW32_LIBS
|
||||
dir=$(echo $PTW32_LIBS | sed -r 's/.*-L([[:graph:]]+).*/\1/g')
|
||||
lib=$(echo $PTW32_LIBS | sed -r 's/.*-l(pthreadGC[[:graph:]]+).*/\1/g')
|
||||
lib="${lib}.dll"
|
||||
if test -r "$dir/$lib"; then
|
||||
cp "$dir/$lib" "$build"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
def="$def -DMINGWM_DLL=$MINGWM_DLL -DPTW32_DLL=$PTW32_DLL"
|
||||
|
||||
$MAKENSIS -V2 -NOCD -D"INSTALLER_FILE=$INSTALLER_FILE" -D"LICENSE_FILE=$data/../COPYING" \
|
||||
-D"SUPPORT_URL=$PACKAGE_HOME" -D"UPDATES_URL=$PACKAGE_DL" $def "$data/win32/fl_app.nsi"
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ flmsg_SOURCES += \
|
|||
$(srcdir)/widgets/date.cxx \
|
||||
$(srcdir)/widgets/fileselect.cxx \
|
||||
$(srcdir)/widgets/flinput2.cxx \
|
||||
$(srcdir)/widgets/flstring.c \
|
||||
$(srcdir)/widgets/Fl_Text_Editor_mod.cxx \
|
||||
$(srcdir)/widgets/Fl_Text_Display_mod.cxx \
|
||||
$(srcdir)/widgets/Fl_Native_File_Chooser.cxx \
|
||||
|
|
@ -213,10 +214,12 @@ EXTRA_DIST = \
|
|||
$(srcdir)/include/crc16.h \
|
||||
$(srcdir)/include/date.h \
|
||||
$(srcdir)/include/debug.h \
|
||||
$(srcdir)/include/dirent-check.h \
|
||||
$(srcdir)/include/fileselect.h \
|
||||
$(srcdir)/include/flmsg_config.h \
|
||||
$(srcdir)/include/flmsgrc.h \
|
||||
$(srcdir)/include/flinput2.h \
|
||||
$(srcdir)/include/flstring.h \
|
||||
$(srcdir)/include/gettext.h \
|
||||
$(srcdir)/include/hx_msgs.h \
|
||||
$(srcdir)/include/iaru.h \
|
||||
|
|
@ -230,8 +233,16 @@ EXTRA_DIST = \
|
|||
$(srcdir)/include/status.h \
|
||||
$(srcdir)/include/util.h \
|
||||
$(srcdir)/include/wrap.h \
|
||||
$(srcdir)/widgets/Fl_Text_Display_mod_1_1.cxx \
|
||||
$(srcdir)/widgets/Fl_Text_Display_mod_1_3.cxx \
|
||||
$(srcdir)/widgets/Fl_Text_Editor_mod_1_1.cxx \
|
||||
$(srcdir)/widgets/Fl_Text_Editor_mod_1_3.cxx \
|
||||
$(srcdir)/include/Fl_Text_Display_mod.H \
|
||||
$(srcdir)/include/Fl_Text_Display_mod_1_1.H \
|
||||
$(srcdir)/include/Fl_Text_Display_mod_1_3.H \
|
||||
$(srcdir)/include/Fl_Text_Editor_mod.H \
|
||||
$(srcdir)/include/Fl_Text_Editor_mod_1_1.H \
|
||||
$(srcdir)/include/Fl_Text_Editor_mod_1_3.H \
|
||||
$(srcdir)/include/FTextView.h \
|
||||
$(srcdir)/include/FL/Fl_Native_File_Chooser_FLTK.H \
|
||||
$(srcdir)/include/FL/Fl_Native_File_Chooser_MAC.H \
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -65,10 +65,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ Fl_Group *h206_tab_resource = (Fl_Group *)0;
|
|||
Fl_Group *h206_tab_staff = (Fl_Group *)0;
|
||||
Fl_Group *h206_tab_medicines = (Fl_Group *)0;
|
||||
Fl_Group *h206_tab_sites = (Fl_Group *)0;
|
||||
Fl_Group *h206_grp1 = (Fl_Group *)0;
|
||||
Fl_Group *h206_grp2 = (Fl_Group *)0;
|
||||
Fl_Group *h206_grp3 = (Fl_Group *)0;
|
||||
Fl_Group *h206_grp4 = (Fl_Group *)0;
|
||||
Fl_Group *h206_grp5 = (Fl_Group *)0;
|
||||
Fl_Group *h206_grp6 = (Fl_Group *)0;
|
||||
|
||||
Fl_Input2 *h206_txt_name = (Fl_Input2 *)0;
|
||||
Fl_Input2 *h206_txt_op_period = (Fl_Input2 *)0;
|
||||
|
|
@ -93,9 +99,9 @@ void create_hics206_tab()
|
|||
h206_tab_type->align(FL_ALIGN_TOP_LEFT);
|
||||
|
||||
h206_tab_plan = new Fl_Group(0, 95, 570, 325, _("Plan"));
|
||||
{
|
||||
Fl_Group* o = new Fl_Group(2, 100, 566, 80);
|
||||
o->box(FL_ENGRAVED_FRAME);
|
||||
|
||||
h206_grp1 = new Fl_Group(2, 100, 566, 80);
|
||||
h206_grp1->box(FL_ENGRAVED_FRAME);
|
||||
h206_txt_name = new Fl_Input2(9, 119, 242, 24, _("Incident Name"));
|
||||
h206_txt_name->tooltip(_(""));
|
||||
h206_txt_name->box(FL_DOWN_BOX);
|
||||
|
|
@ -152,11 +158,10 @@ void create_hics206_tab()
|
|||
h206_btn_date->tooltip(_("Set today"));
|
||||
h206_btn_date->callback((Fl_Callback*)cb_btn_h206date);
|
||||
|
||||
o->end();
|
||||
}
|
||||
{
|
||||
Fl_Group* o = new Fl_Group(2, 182, 566, 30);
|
||||
o->box(FL_ENGRAVED_FRAME);
|
||||
h206_grp1->end();
|
||||
|
||||
h206_grp2 = new Fl_Group(2, 182, 566, 30);
|
||||
h206_grp2->box(FL_ENGRAVED_FRAME);
|
||||
h206_txt_preparer = new Fl_Input2(71, 184, 210, 24, _("Preparer"));
|
||||
h206_txt_preparer->tooltip(_(""));
|
||||
h206_txt_preparer->box(FL_DOWN_BOX);
|
||||
|
|
@ -181,12 +186,12 @@ void create_hics206_tab()
|
|||
h206_txt_facility->align(FL_ALIGN_LEFT);
|
||||
h206_txt_facility->when(FL_WHEN_RELEASE);
|
||||
|
||||
o->end();
|
||||
}
|
||||
h206_grp2->end();
|
||||
|
||||
h206_tab_plan->end();
|
||||
|
||||
h206_tab_treatment = new Fl_Group(0, 95, 570, 325, _("Trmnt"));
|
||||
{
|
||||
|
||||
h206_txt_location = new Fl_Input2(4, 119, 278, 24, _("Location"));
|
||||
h206_txt_location->tooltip(_("location of staff treatment area"));
|
||||
h206_txt_location->box(FL_DOWN_BOX);
|
||||
|
|
@ -245,14 +250,14 @@ void create_hics206_tab()
|
|||
h206_txt_special_instructions->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
|
||||
h206_txt_special_instructions->align(FL_ALIGN_TOP_LEFT);
|
||||
h206_txt_special_instructions->when(FL_WHEN_RELEASE);
|
||||
}
|
||||
|
||||
h206_tab_treatment->end();
|
||||
|
||||
h206_tab_staff = new Fl_Group(0, 95, 570, 325, _("Staff/Trans'"));
|
||||
{
|
||||
Fl_Group *grp1 = new Fl_Group(2, 98, 566, 155, "Staff");
|
||||
grp1->box(FL_ENGRAVED_FRAME);
|
||||
grp1->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
|
||||
|
||||
h206_grp3 = new Fl_Group(2, 98, 566, 155, "Staff");
|
||||
h206_grp3->box(FL_ENGRAVED_FRAME);
|
||||
h206_grp3->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
|
||||
|
||||
h206_txt_md_do = new Fl_Input2(110, 120, 445, 24, _("MD/DO"));
|
||||
h206_txt_md_do->tooltip(_("medical doctor"));
|
||||
|
|
@ -313,11 +318,11 @@ void create_hics206_tab()
|
|||
h206_txt_team_other->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
|
||||
h206_txt_team_other->align(FL_ALIGN_LEFT);
|
||||
h206_txt_team_other->when(FL_WHEN_RELEASE);
|
||||
grp1->end();
|
||||
h206_grp3->end();
|
||||
|
||||
Fl_Group *grp2 = new Fl_Group(2, 255, 566, 165, "Transportation");
|
||||
grp2->box(FL_ENGRAVED_FRAME);
|
||||
grp2->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
|
||||
h206_grp4 = new Fl_Group(2, 255, 566, 165, "Transportation");
|
||||
h206_grp4->box(FL_ENGRAVED_FRAME);
|
||||
h206_grp4->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
|
||||
|
||||
h206_txt_litters = new Fl_Input2(110, 280, 445, 24, _("Litters"));
|
||||
h206_txt_litters->tooltip(_(""));
|
||||
|
|
@ -378,14 +383,16 @@ void create_hics206_tab()
|
|||
h206_txt_transport_other->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
|
||||
h206_txt_transport_other->align(FL_ALIGN_LEFT);
|
||||
h206_txt_transport_other->when(FL_WHEN_RELEASE);
|
||||
}
|
||||
|
||||
h206_grp4->end();
|
||||
|
||||
h206_tab_staff->end();
|
||||
|
||||
h206_tab_medicines = new Fl_Group(0, 95, 570, 325, _("Med/Supply"));
|
||||
{
|
||||
Fl_Group *grp1 = new Fl_Group(2, 98, 566, 155, "Medicines");
|
||||
grp1->box(FL_ENGRAVED_FRAME);
|
||||
grp1->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
|
||||
|
||||
Fl_Group *h206_grp5 = new Fl_Group(2, 98, 566, 155, "Medicines");
|
||||
h206_grp5->box(FL_ENGRAVED_FRAME);
|
||||
h206_grp5->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
|
||||
|
||||
h206_txt_meds_1 = new Fl_Input2(110, 120, 445, 24, _("Medicine"));
|
||||
h206_txt_meds_1->tooltip(_(""));
|
||||
|
|
@ -448,11 +455,11 @@ void create_hics206_tab()
|
|||
h206_txt_meds_5->align(FL_ALIGN_LEFT);
|
||||
h206_txt_meds_5->when(FL_WHEN_RELEASE);
|
||||
|
||||
grp1->end();
|
||||
h206_grp5->end();
|
||||
|
||||
Fl_Group *grp2 = new Fl_Group(2, 255, 566, 165, "Supplies");
|
||||
grp2->box(FL_ENGRAVED_FRAME);
|
||||
grp2->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
|
||||
h206_grp6 = new Fl_Group(2, 255, 566, 165, "Supplies");
|
||||
h206_grp6->box(FL_ENGRAVED_FRAME);
|
||||
h206_grp6->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
|
||||
|
||||
h206_txt_supp_1 = new Fl_Input2(110, 280, 445, 24, _("Supply"));
|
||||
h206_txt_supp_1->tooltip(_(""));
|
||||
|
|
@ -514,11 +521,11 @@ void create_hics206_tab()
|
|||
h206_txt_supp_5->align(FL_ALIGN_LEFT);
|
||||
h206_txt_supp_5->when(FL_WHEN_RELEASE);
|
||||
|
||||
}
|
||||
h206_grp6->end();
|
||||
|
||||
h206_tab_medicines->end();
|
||||
|
||||
h206_tab_sites = new Fl_Group(0, 95, 570, 325, _("Sites"));
|
||||
{
|
||||
h206_txt_site_1 = new Fl_Input2(80, 110, 200, 24, _("Name"));
|
||||
h206_txt_site_1->tooltip(_(""));
|
||||
h206_txt_site_1->box(FL_DOWN_BOX);
|
||||
|
|
@ -711,9 +718,8 @@ void create_hics206_tab()
|
|||
h206_txt_spec_care_4->align(FL_ALIGN_LEFT);
|
||||
h206_txt_spec_care_4->when(FL_WHEN_RELEASE);
|
||||
|
||||
}
|
||||
h206_tab_sites->end();
|
||||
|
||||
|
||||
h206_tab_type->end();
|
||||
Fl_Group::current()->resizable(h206_tab_type);
|
||||
h206_tab->end();
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
// FTextView.h
|
||||
//
|
||||
// Copyright (C) 2007
|
||||
// Copyright (C) 2007-2009
|
||||
// Stelios Bounanos, M0GLD
|
||||
//
|
||||
// Interface based on the text widgets by Dave Freese, W1HKJ.
|
||||
//
|
||||
// This file is part of fldigi.
|
||||
//
|
||||
// fldigi is free software; you can redistribute it and/or modify
|
||||
|
|
@ -50,14 +48,14 @@ public:
|
|||
FTextBase(int x, int y, int w, int h, const char *l = 0);
|
||||
virtual ~FTextBase() { delete tbuf; delete sbuf; }
|
||||
|
||||
virtual void add(const char *text, int attr = RECV) = 0;
|
||||
virtual void add(unsigned char c, int attr = RECV) = 0;
|
||||
virtual void add(const char *text, int attr = RECV);
|
||||
virtual void add(unsigned char c, int attr = RECV);
|
||||
void addstr(const char *text, int attr = RECV) { add(text, attr); }
|
||||
void addchr(unsigned char c, int attr = RECV) { add(c, attr); }
|
||||
|
||||
virtual int handle(int event);
|
||||
virtual void handle_context_menu(void) { }
|
||||
void clear(void) { tbuf->text(""); sbuf->text(""); }
|
||||
virtual void clear(void);//{ tbuf->text(""); sbuf->text(""); }
|
||||
|
||||
void set_word_wrap(bool b);
|
||||
bool get_word_wrap(void) { return wrap; }
|
||||
|
|
@ -81,12 +79,16 @@ protected:
|
|||
int set = SET_FONT | SET_SIZE | SET_COLOR);
|
||||
int readFile(const char* fn = 0);
|
||||
void saveFile(void);
|
||||
char* get_word(int x, int y, bool ontext = true);
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
char* get_word(int x, int y, const char* nwchars = "", bool ontext = true);
|
||||
#else
|
||||
char* get_word(int x, int y, bool ontext = true);
|
||||
#endif
|
||||
void init_context_menu(void);
|
||||
void show_context_menu(void);
|
||||
virtual void menu_cb(size_t item) { }
|
||||
int reset_wrap_col(void);
|
||||
void reset_styles(int set);
|
||||
void reset_styles(int set);
|
||||
private:
|
||||
FTextBase();
|
||||
FTextBase(const FTextBase &t);
|
||||
|
|
@ -94,8 +96,8 @@ private:
|
|||
protected:
|
||||
enum { FTEXT_DEF = 'A' };
|
||||
enum set_style_op_e { SET_FONT = 1 << 0, SET_SIZE = 1 << 1, SET_COLOR = 1 << 2 };
|
||||
Fl_Text_Buffer *tbuf; ///< text buffer
|
||||
Fl_Text_Buffer *sbuf; ///< style buffer
|
||||
Fl_Text_Buffer_mod *tbuf; ///< text buffer
|
||||
Fl_Text_Buffer_mod *sbuf; ///< style buffer
|
||||
Fl_Text_Display_mod::Style_Table_Entry styles[NATTR];
|
||||
Fl_Menu_Item *context_menu;
|
||||
int popx, popy;
|
||||
|
|
@ -103,6 +105,8 @@ protected:
|
|||
int wrap_col;
|
||||
int max_lines;
|
||||
bool scroll_hint;
|
||||
bool restore_wrap;
|
||||
// bool wrap_restore;
|
||||
|
||||
private:
|
||||
int oldw, oldh, olds;
|
||||
|
|
@ -119,12 +123,6 @@ public:
|
|||
~FTextView() { }
|
||||
|
||||
virtual int handle(int event);
|
||||
virtual void add(unsigned char c, int attr = RECV);
|
||||
virtual void add(const char *s, int attr = RECV)
|
||||
{
|
||||
while (*s)
|
||||
add(*s++, attr);
|
||||
}
|
||||
|
||||
protected:
|
||||
enum {
|
||||
|
|
@ -158,9 +156,6 @@ public:
|
|||
|
||||
virtual int handle(int event);
|
||||
|
||||
virtual void add(const char *s, int attr = RECV);
|
||||
virtual void add(unsigned char c, int attr = RECV);
|
||||
|
||||
protected:
|
||||
enum {
|
||||
EDIT_MENU_CUT, EDIT_MENU_COPY, EDIT_MENU_PASTE, EDIT_MENU_CLEAR,
|
||||
|
|
|
|||
|
|
@ -1,304 +1,7 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Display.H 4502 2005-08-10 23:11:51Z matt $"
|
||||
//
|
||||
// Header file for Fl_Text_Display class.
|
||||
//
|
||||
// Copyright 2001-2005 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#ifndef FL_TEXT_DISPLAY_MOD_H
|
||||
#define FL_TEXT_DISPLAY_MOD_H
|
||||
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <FL/Fl_Scrollbar.H>
|
||||
#include <FL/Fl_Text_Buffer.H>
|
||||
|
||||
class Fl_Text_Display_mod: public Fl_Group {
|
||||
public:
|
||||
enum {
|
||||
NORMAL_CURSOR, CARET_CURSOR, DIM_CURSOR,
|
||||
BLOCK_CURSOR, HEAVY_CURSOR
|
||||
};
|
||||
|
||||
enum {
|
||||
CURSOR_POS, CHARACTER_POS
|
||||
};
|
||||
|
||||
// drag types- they match Fl::event_clicks() so that single clicking to
|
||||
// start a collection selects by character, double clicking selects by
|
||||
// word and triple clicking selects by line.
|
||||
enum {
|
||||
DRAG_CHAR = 0, DRAG_WORD = 1, DRAG_LINE = 2
|
||||
};
|
||||
friend void fl_text_drag_me(int pos, Fl_Text_Display_mod* d);
|
||||
|
||||
typedef void (*Unfinished_Style_Cb)(int, void *);
|
||||
|
||||
// style attributes - currently not implemented!
|
||||
enum {
|
||||
ATTR_NONE = 0,
|
||||
ATTR_UNDERLINE = 1,
|
||||
ATTR_HIDDEN = 2
|
||||
};
|
||||
|
||||
struct Style_Table_Entry {
|
||||
Fl_Color color;
|
||||
Fl_Font font;
|
||||
int size;
|
||||
unsigned attr;
|
||||
};
|
||||
|
||||
Fl_Text_Display_mod(int X, int Y, int W, int H, const char *l = 0);
|
||||
~Fl_Text_Display_mod();
|
||||
|
||||
virtual int handle(int e);
|
||||
void buffer(Fl_Text_Buffer* buf);
|
||||
void buffer(Fl_Text_Buffer& buf) { buffer(&buf); }
|
||||
Fl_Text_Buffer* buffer() { return mBuffer; }
|
||||
void redisplay_range(int start, int end);
|
||||
void scroll(int topLineNum, int horizOffset);
|
||||
void insert(const char* text);
|
||||
void overstrike(const char* text);
|
||||
void insert_position(int newPos);
|
||||
int insert_position() { return mCursorPos; }
|
||||
int in_selection(int x, int y);
|
||||
void show_insert_position();
|
||||
int move_right();
|
||||
int move_left();
|
||||
int move_up();
|
||||
int move_down();
|
||||
int count_lines(int start, int end, bool start_pos_is_line_start);
|
||||
int line_start(int pos);
|
||||
int line_end(int pos, bool start_pos_is_line_start);
|
||||
int skip_lines(int startPos, int nLines, bool startPosIsLineStart);
|
||||
int rewind_lines(int startPos, int nLines);
|
||||
void next_word(void);
|
||||
void previous_word(void);
|
||||
void show_cursor(int b = 1);
|
||||
void hide_cursor() { show_cursor(0); }
|
||||
void cursor_style(int style);
|
||||
Fl_Color cursor_color() const {return mCursor_color;}
|
||||
void cursor_color(Fl_Color n) {mCursor_color = n;}
|
||||
int scrollbar_width() { return scrollbar_width_; }
|
||||
Fl_Align scrollbar_align() { return scrollbar_align_; }
|
||||
void scrollbar_width(int W) { scrollbar_width_ = W; }
|
||||
void scrollbar_align(Fl_Align a) { scrollbar_align_ = a; }
|
||||
int word_start(int pos) { return buffer()->word_start(pos); }
|
||||
int word_end(int pos) { return buffer()->word_end(pos); }
|
||||
|
||||
|
||||
void highlight_data(Fl_Text_Buffer *styleBuffer,
|
||||
const Style_Table_Entry *styleTable,
|
||||
int nStyles, char unfinishedStyle,
|
||||
Unfinished_Style_Cb unfinishedHighlightCB,
|
||||
void *cbArg);
|
||||
|
||||
int position_style(int lineStartPos, int lineLen, int lineIndex,
|
||||
int dispIndex);
|
||||
|
||||
Fl_Font textfont() const {return textfont_;}
|
||||
void textfont(Fl_Font f) {textfont_ = f;}
|
||||
uchar textsize() const {return textsize_;}
|
||||
void textsize(uchar s) {textsize_ = s;}
|
||||
Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
|
||||
void textcolor(unsigned n) {textcolor_ = n;}
|
||||
|
||||
int wrapped_column(int row, int column);
|
||||
int wrapped_row(int row);
|
||||
void wrap_mode(int wrap, int wrap_margin);
|
||||
|
||||
virtual void resize(int X, int Y, int W, int H);
|
||||
|
||||
protected:
|
||||
// Most (all?) of this stuff should only be called from resize() or
|
||||
// draw().
|
||||
// Anything with "vline" indicates thats it deals with currently
|
||||
// visible lines.
|
||||
|
||||
virtual void draw();
|
||||
void draw_text(int X, int Y, int W, int H);
|
||||
void draw_range(int start, int end);
|
||||
void draw_cursor(int, int);
|
||||
|
||||
void draw_string(int style, int x, int y, int toX, const char *string,
|
||||
int nChars);
|
||||
|
||||
void draw_vline(int visLineNum, int leftClip, int rightClip,
|
||||
int leftCharIndex, int rightCharIndex);
|
||||
|
||||
void draw_line_numbers(bool clearAll);
|
||||
|
||||
void clear_rect(int style, int x, int y, int width, int height);
|
||||
void display_insert();
|
||||
|
||||
void offset_line_starts(int newTopLineNum);
|
||||
|
||||
void calc_line_starts(int startLine, int endLine);
|
||||
|
||||
void update_line_starts(int pos, int charsInserted, int charsDeleted,
|
||||
int linesInserted, int linesDeleted, int *scrolled);
|
||||
|
||||
void calc_last_char();
|
||||
|
||||
int position_to_line( int pos, int* lineNum );
|
||||
int string_width(const char* string, int length, int style);
|
||||
|
||||
static void scroll_timer_cb(void*);
|
||||
|
||||
static void buffer_predelete_cb(int pos, int nDeleted, void* cbArg);
|
||||
static void buffer_modified_cb(int pos, int nInserted, int nDeleted,
|
||||
int nRestyled, const char* deletedText,
|
||||
void* cbArg);
|
||||
|
||||
static void h_scrollbar_cb(Fl_Scrollbar* w, Fl_Text_Display_mod* d);
|
||||
static void v_scrollbar_cb( Fl_Scrollbar* w, Fl_Text_Display_mod* d);
|
||||
void update_v_scrollbar();
|
||||
void update_h_scrollbar();
|
||||
int measure_vline(int visLineNum);
|
||||
int longest_vline();
|
||||
int empty_vlines();
|
||||
int vline_length(int visLineNum);
|
||||
int xy_to_position(int x, int y, int PosType = CHARACTER_POS);
|
||||
|
||||
void xy_to_rowcol(int x, int y, int* row, int* column,
|
||||
int PosType = CHARACTER_POS);
|
||||
|
||||
int position_to_xy(int pos, int* x, int* y);
|
||||
void maintain_absolute_top_line_number(int state);
|
||||
int get_absolute_top_line_number();
|
||||
void absolute_top_line_number(int oldFirstChar);
|
||||
int maintaining_absolute_top_line_number();
|
||||
void reset_absolute_top_line_number();
|
||||
int position_to_linecol(int pos, int* lineNum, int* column);
|
||||
void scroll_(int topLineNum, int horizOffset);
|
||||
|
||||
void extend_range_for_styles(int* start, int* end);
|
||||
|
||||
void find_wrap_range(const char *deletedText, int pos, int nInserted,
|
||||
int nDeleted, int *modRangeStart, int *modRangeEnd,
|
||||
int *linesInserted, int *linesDeleted);
|
||||
void measure_deleted_lines(int pos, int nDeleted);
|
||||
void wrapped_line_counter(Fl_Text_Buffer *buf, int startPos, int maxPos,
|
||||
int maxLines, bool startPosIsLineStart,
|
||||
int styleBufOffset, int *retPos, int *retLines,
|
||||
int *retLineStart, int *retLineEnd,
|
||||
bool countLastLineMissingNewLine = true);
|
||||
void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd,
|
||||
int *nextLineStart);
|
||||
int measure_proportional_character(char c, int colNum, int pos);
|
||||
int wrap_uses_character(int lineEndPos);
|
||||
int range_touches_selection(Fl_Text_Selection *sel, int rangeStart,
|
||||
int rangeEnd);
|
||||
|
||||
static const int DEFAULT_TOP_MARGIN;
|
||||
static const int DEFAULT_BOTTOM_MARGIN;
|
||||
static const int DEFAULT_LEFT_MARGIN;
|
||||
static const int DEFAULT_RIGHT_MARGIN;
|
||||
int TOP_MARGIN, BOTTOM_MARGIN, LEFT_MARGIN, RIGHT_MARGIN;
|
||||
|
||||
int damage_range1_start, damage_range1_end;
|
||||
int damage_range2_start, damage_range2_end;
|
||||
int mCursorPos;
|
||||
int mCursorOn;
|
||||
int mCursorOldY; /* Y pos. of cursor for blanking */
|
||||
int mCursorToHint; /* Tells the buffer modified callback
|
||||
where to move the cursor, to reduce
|
||||
the number of redraw calls */
|
||||
int mCursorStyle; /* One of enum cursorStyles above */
|
||||
int mCursorPreferredCol; /* Column for vert. cursor movement */
|
||||
int mNVisibleLines; /* # of visible (displayed) lines */
|
||||
int mNBufferLines; /* # of newlines in the buffer */
|
||||
Fl_Text_Buffer* mBuffer; /* Contains text to be displayed */
|
||||
Fl_Text_Buffer* mStyleBuffer; /* Optional parallel buffer containing
|
||||
color and font information */
|
||||
int mFirstChar, mLastChar; /* Buffer positions of first and last
|
||||
displayed character (lastChar points
|
||||
either to a newline or one character
|
||||
beyond the end of the buffer) */
|
||||
int mContinuousWrap; /* Wrap long lines when displaying */
|
||||
int mWrapMargin; /* Margin in # of char positions for
|
||||
wrapping in continuousWrap mode */
|
||||
int* mLineStarts;
|
||||
int mTopLineNum; /* Line number of top displayed line
|
||||
of file (first line of file is 1) */
|
||||
int mAbsTopLineNum; /* In continuous wrap mode, the line
|
||||
number of the top line if the text
|
||||
were not wrapped (note that this is
|
||||
only maintained as needed). */
|
||||
int mNeedAbsTopLineNum; /* Externally settable flag to continue
|
||||
maintaining absTopLineNum even if
|
||||
it isn't needed for line # display */
|
||||
int mHorizOffset; /* Horizontal scroll pos. in pixels */
|
||||
int mTopLineNumHint; /* Line number of top displayed line
|
||||
of file (first line of file is 1) */
|
||||
int mHorizOffsetHint; /* Horizontal scroll pos. in pixels */
|
||||
int mNStyles; /* Number of entries in styleTable */
|
||||
const Style_Table_Entry *mStyleTable; /* Table of fonts and colors for
|
||||
coloring/syntax-highlighting */
|
||||
char mUnfinishedStyle; /* Style buffer entry which triggers
|
||||
on-the-fly reparsing of region */
|
||||
Unfinished_Style_Cb mUnfinishedHighlightCB; /* Callback to parse "unfinished" */
|
||||
/* regions */
|
||||
void* mHighlightCBArg; /* Arg to unfinishedHighlightCB */
|
||||
|
||||
int mMaxsize;
|
||||
|
||||
int mFixedFontWidth; /* Font width if all current fonts are
|
||||
fixed and match in width, else -1 */
|
||||
int mSuppressResync; /* Suppress resynchronization of line
|
||||
starts during buffer updates */
|
||||
int mNLinesDeleted; /* Number of lines deleted during
|
||||
buffer modification (only used
|
||||
when resynchronization is suppressed) */
|
||||
int mModifyingTabDistance; /* Whether tab distance is being
|
||||
modified */
|
||||
|
||||
Fl_Color mCursor_color;
|
||||
|
||||
Fl_Scrollbar* mHScrollBar;
|
||||
Fl_Scrollbar* mVScrollBar;
|
||||
int scrollbar_width_;
|
||||
Fl_Align scrollbar_align_;
|
||||
int dragPos, dragType, dragging;
|
||||
int display_insert_position_hint;
|
||||
struct { int x, y, w, h; } text_area;
|
||||
|
||||
Fl_Font textfont_;
|
||||
uchar textsize_;
|
||||
unsigned textcolor_;
|
||||
|
||||
// The following are not presently used from the original NEdit code,
|
||||
// but are being put here so that future versions of Fl_Text_Display
|
||||
// can implement line numbers without breaking binary compatibility.
|
||||
int mLineNumLeft, mLineNumWidth;
|
||||
/* Line number margin and width */
|
||||
};
|
||||
#include <config.h>
|
||||
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
# include "Fl_Text_Display_mod_1_1.H"
|
||||
#elif FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR == 3
|
||||
# include "Fl_Text_Display_mod_1_3.H"
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Text_Display.H 4502 2005-08-10 23:11:51Z matt $".
|
||||
//
|
||||
|
|
|
|||
306
src/include/Fl_Text_Display_mod_1_1.H
Normal file
306
src/include/Fl_Text_Display_mod_1_1.H
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Display.H 4502 2005-08-10 23:11:51Z matt $"
|
||||
//
|
||||
// Header file for Fl_Text_Display class.
|
||||
//
|
||||
// Copyright 2001-2005 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#ifndef FL_TEXT_DISPLAY_MOD_H
|
||||
#define FL_TEXT_DISPLAY_MOD_H
|
||||
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <FL/Fl_Scrollbar.H>
|
||||
#include <FL/Fl_Text_Buffer.H>
|
||||
|
||||
#define Fl_Text_Buffer_mod Fl_Text_Buffer
|
||||
|
||||
class Fl_Text_Display_mod: public Fl_Group {
|
||||
public:
|
||||
enum {
|
||||
NORMAL_CURSOR, CARET_CURSOR, DIM_CURSOR,
|
||||
BLOCK_CURSOR, HEAVY_CURSOR
|
||||
};
|
||||
|
||||
enum {
|
||||
CURSOR_POS, CHARACTER_POS
|
||||
};
|
||||
|
||||
// drag types- they match Fl::event_clicks() so that single clicking to
|
||||
// start a collection selects by character, double clicking selects by
|
||||
// word and triple clicking selects by line.
|
||||
enum {
|
||||
DRAG_CHAR = 0, DRAG_WORD = 1, DRAG_LINE = 2
|
||||
};
|
||||
friend void fl_text_drag_me(int pos, Fl_Text_Display_mod* d);
|
||||
|
||||
typedef void (*Unfinished_Style_Cb)(int, void *);
|
||||
|
||||
// style attributes - currently not implemented!
|
||||
enum {
|
||||
ATTR_NONE = 0,
|
||||
ATTR_UNDERLINE = 1,
|
||||
ATTR_HIDDEN = 2
|
||||
};
|
||||
|
||||
struct Style_Table_Entry {
|
||||
Fl_Color color;
|
||||
Fl_Font font;
|
||||
int size;
|
||||
unsigned attr;
|
||||
};
|
||||
|
||||
Fl_Text_Display_mod(int X, int Y, int W, int H, const char *l = 0);
|
||||
~Fl_Text_Display_mod();
|
||||
|
||||
virtual int handle(int e);
|
||||
void buffer(Fl_Text_Buffer_mod* buf);
|
||||
void buffer(Fl_Text_Buffer_mod& buf) { buffer(&buf); }
|
||||
Fl_Text_Buffer_mod* buffer() { return mBuffer; }
|
||||
void redisplay_range(int start, int end);
|
||||
void scroll(int topLineNum, int horizOffset);
|
||||
void insert(const char* text);
|
||||
void overstrike(const char* text);
|
||||
void insert_position(int newPos);
|
||||
int insert_position() { return mCursorPos; }
|
||||
int in_selection(int x, int y);
|
||||
void show_insert_position();
|
||||
int move_right();
|
||||
int move_left();
|
||||
int move_up();
|
||||
int move_down();
|
||||
int count_lines(int start, int end, bool start_pos_is_line_start);
|
||||
int line_start(int pos);
|
||||
int line_end(int pos, bool start_pos_is_line_start);
|
||||
int skip_lines(int startPos, int nLines, bool startPosIsLineStart);
|
||||
int rewind_lines(int startPos, int nLines);
|
||||
void next_word(void);
|
||||
void previous_word(void);
|
||||
void show_cursor(int b = 1);
|
||||
void hide_cursor() { show_cursor(0); }
|
||||
void cursor_style(int style);
|
||||
Fl_Color cursor_color() const {return mCursor_color;}
|
||||
void cursor_color(Fl_Color n) {mCursor_color = n;}
|
||||
int scrollbar_width() { return scrollbar_width_; }
|
||||
Fl_Align scrollbar_align() { return scrollbar_align_; }
|
||||
void scrollbar_width(int W) { scrollbar_width_ = W; }
|
||||
void scrollbar_align(Fl_Align a) { scrollbar_align_ = a; }
|
||||
int word_start(int pos) { return buffer()->word_start(pos); }
|
||||
int word_end(int pos) { return buffer()->word_end(pos); }
|
||||
|
||||
|
||||
void highlight_data(Fl_Text_Buffer_mod *styleBuffer,
|
||||
const Style_Table_Entry *styleTable,
|
||||
int nStyles, char unfinishedStyle,
|
||||
Unfinished_Style_Cb unfinishedHighlightCB,
|
||||
void *cbArg);
|
||||
|
||||
int position_style(int lineStartPos, int lineLen, int lineIndex,
|
||||
int dispIndex);
|
||||
|
||||
Fl_Font textfont() const {return textfont_;}
|
||||
void textfont(Fl_Font f) {textfont_ = f;}
|
||||
uchar textsize() const {return textsize_;}
|
||||
void textsize(uchar s) {textsize_ = s;}
|
||||
Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
|
||||
void textcolor(unsigned n) {textcolor_ = n;}
|
||||
|
||||
int wrapped_column(int row, int column);
|
||||
int wrapped_row(int row);
|
||||
void wrap_mode(int wrap, int wrap_margin);
|
||||
|
||||
virtual void resize(int X, int Y, int W, int H);
|
||||
|
||||
protected:
|
||||
// Most (all?) of this stuff should only be called from resize() or
|
||||
// draw().
|
||||
// Anything with "vline" indicates thats it deals with currently
|
||||
// visible lines.
|
||||
|
||||
virtual void draw();
|
||||
void draw_text(int X, int Y, int W, int H);
|
||||
void draw_range(int start, int end);
|
||||
void draw_cursor(int, int);
|
||||
|
||||
void draw_string(int style, int x, int y, int toX, const char *string,
|
||||
int nChars);
|
||||
|
||||
void draw_vline(int visLineNum, int leftClip, int rightClip,
|
||||
int leftCharIndex, int rightCharIndex);
|
||||
|
||||
void draw_line_numbers(bool clearAll);
|
||||
|
||||
void clear_rect(int style, int x, int y, int width, int height);
|
||||
void display_insert();
|
||||
|
||||
void offset_line_starts(int newTopLineNum);
|
||||
|
||||
void calc_line_starts(int startLine, int endLine);
|
||||
|
||||
void update_line_starts(int pos, int charsInserted, int charsDeleted,
|
||||
int linesInserted, int linesDeleted, int *scrolled);
|
||||
|
||||
void calc_last_char();
|
||||
|
||||
int position_to_line( size_t pos, int* lineNum);//int pos, int* lineNum );
|
||||
int string_width(const char* string, int length, int style);
|
||||
|
||||
static void scroll_timer_cb(void*);
|
||||
|
||||
static void buffer_predelete_cb(int pos, int nDeleted, void* cbArg);
|
||||
static void buffer_modified_cb(int pos, int nInserted, int nDeleted,
|
||||
int nRestyled, const char* deletedText,
|
||||
void* cbArg);
|
||||
|
||||
static void h_scrollbar_cb(Fl_Scrollbar* w, Fl_Text_Display_mod* d);
|
||||
static void v_scrollbar_cb( Fl_Scrollbar* w, Fl_Text_Display_mod* d);
|
||||
void update_v_scrollbar();
|
||||
void update_h_scrollbar();
|
||||
int measure_vline(int visLineNum);
|
||||
int longest_vline();
|
||||
int empty_vlines();
|
||||
int vline_length(int visLineNum);
|
||||
int xy_to_position(int x, int y, int PosType = CHARACTER_POS);
|
||||
|
||||
void xy_to_rowcol(int x, int y, int* row, int* column,
|
||||
int PosType = CHARACTER_POS);
|
||||
|
||||
int position_to_xy(int pos, int* x, int* y);
|
||||
void maintain_absolute_top_line_number(int state);
|
||||
int get_absolute_top_line_number();
|
||||
void absolute_top_line_number(int oldFirstChar);
|
||||
int maintaining_absolute_top_line_number();
|
||||
void reset_absolute_top_line_number();
|
||||
int position_to_linecol(int pos, int* lineNum, int* column);
|
||||
void scroll_(int topLineNum, int horizOffset);
|
||||
|
||||
void extend_range_for_styles(int* start, int* end);
|
||||
|
||||
void find_wrap_range(const char *deletedText, int pos, int nInserted,
|
||||
int nDeleted, int *modRangeStart, int *modRangeEnd,
|
||||
int *linesInserted, int *linesDeleted);
|
||||
void measure_deleted_lines(int pos, int nDeleted);
|
||||
void wrapped_line_counter(Fl_Text_Buffer_mod *buf, int startPos, int maxPos,
|
||||
int maxLines, bool startPosIsLineStart,
|
||||
int styleBufOffset, int *retPos, int *retLines,
|
||||
int *retLineStart, int *retLineEnd,
|
||||
bool countLastLineMissingNewLine = true);
|
||||
void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd,
|
||||
int *nextLineStart);
|
||||
int measure_proportional_character(char c, int colNum, int pos);
|
||||
int wrap_uses_character(int lineEndPos);
|
||||
int range_touches_selection(Fl_Text_Selection *sel, int rangeStart,
|
||||
int rangeEnd);
|
||||
|
||||
static const int DEFAULT_TOP_MARGIN;
|
||||
static const int DEFAULT_BOTTOM_MARGIN;
|
||||
static const int DEFAULT_LEFT_MARGIN;
|
||||
static const int DEFAULT_RIGHT_MARGIN;
|
||||
int TOP_MARGIN, BOTTOM_MARGIN, LEFT_MARGIN, RIGHT_MARGIN;
|
||||
|
||||
int damage_range1_start, damage_range1_end;
|
||||
int damage_range2_start, damage_range2_end;
|
||||
int mCursorPos;
|
||||
int mCursorOn;
|
||||
int mCursorOldY; /* Y pos. of cursor for blanking */
|
||||
int mCursorToHint; /* Tells the buffer modified callback
|
||||
where to move the cursor, to reduce
|
||||
the number of redraw calls */
|
||||
int mCursorStyle; /* One of enum cursorStyles above */
|
||||
int mCursorPreferredCol; /* Column for vert. cursor movement */
|
||||
int mNVisibleLines; /* # of visible (displayed) lines */
|
||||
int mNBufferLines; /* # of newlines in the buffer */
|
||||
Fl_Text_Buffer_mod* mBuffer; /* Contains text to be displayed */
|
||||
Fl_Text_Buffer_mod* mStyleBuffer; /* Optional parallel buffer containing
|
||||
color and font information */
|
||||
int mFirstChar, mLastChar; /* Buffer positions of first and last
|
||||
displayed character (lastChar points
|
||||
either to a newline or one character
|
||||
beyond the end of the buffer) */
|
||||
int mContinuousWrap; /* Wrap long lines when displaying */
|
||||
int mWrapMargin; /* Margin in # of char positions for
|
||||
wrapping in continuousWrap mode */
|
||||
int* mLineStarts;
|
||||
int mTopLineNum; /* Line number of top displayed line
|
||||
of file (first line of file is 1) */
|
||||
int mAbsTopLineNum; /* In continuous wrap mode, the line
|
||||
number of the top line if the text
|
||||
were not wrapped (note that this is
|
||||
only maintained as needed). */
|
||||
int mNeedAbsTopLineNum; /* Externally settable flag to continue
|
||||
maintaining absTopLineNum even if
|
||||
it isn't needed for line # display */
|
||||
int mHorizOffset; /* Horizontal scroll pos. in pixels */
|
||||
int mTopLineNumHint; /* Line number of top displayed line
|
||||
of file (first line of file is 1) */
|
||||
int mHorizOffsetHint; /* Horizontal scroll pos. in pixels */
|
||||
int mNStyles; /* Number of entries in styleTable */
|
||||
const Style_Table_Entry *mStyleTable; /* Table of fonts and colors for
|
||||
coloring/syntax-highlighting */
|
||||
char mUnfinishedStyle; /* Style buffer entry which triggers
|
||||
on-the-fly reparsing of region */
|
||||
Unfinished_Style_Cb mUnfinishedHighlightCB; /* Callback to parse "unfinished" */
|
||||
/* regions */
|
||||
void* mHighlightCBArg; /* Arg to unfinishedHighlightCB */
|
||||
|
||||
int mMaxsize;
|
||||
|
||||
int mFixedFontWidth; /* Font width if all current fonts are
|
||||
fixed and match in width, else -1 */
|
||||
int mSuppressResync; /* Suppress resynchronization of line
|
||||
starts during buffer updates */
|
||||
int mNLinesDeleted; /* Number of lines deleted during
|
||||
buffer modification (only used
|
||||
when resynchronization is suppressed) */
|
||||
int mModifyingTabDistance; /* Whether tab distance is being
|
||||
modified */
|
||||
|
||||
Fl_Color mCursor_color;
|
||||
|
||||
Fl_Scrollbar* mHScrollBar;
|
||||
Fl_Scrollbar* mVScrollBar;
|
||||
int scrollbar_width_;
|
||||
Fl_Align scrollbar_align_;
|
||||
int dragPos, dragType, dragging;
|
||||
int display_insert_position_hint;
|
||||
struct { int x, y, w, h; } text_area;
|
||||
|
||||
Fl_Font textfont_;
|
||||
uchar textsize_;
|
||||
unsigned textcolor_;
|
||||
|
||||
// The following are not presently used from the original NEdit code,
|
||||
// but are being put here so that future versions of Fl_Text_Display
|
||||
// can implement line numbers without breaking binary compatibility.
|
||||
int mLineNumLeft, mLineNumWidth;
|
||||
/* Line number margin and width */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Text_Display.H 4502 2005-08-10 23:11:51Z matt $".
|
||||
//
|
||||
49
src/include/Fl_Text_Display_mod_1_3.H
Normal file
49
src/include/Fl_Text_Display_mod_1_3.H
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Display_mod.H 8306 2011-01-24 17:04:22Z matt $"
|
||||
//
|
||||
// Header file for Fl_Text_Display_mod class.
|
||||
//
|
||||
// Copyright 2001-2010 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Text_Display_mod widget . */
|
||||
|
||||
#ifndef FL_TEXT_DISPLAY_MOD_H
|
||||
#define FL_TEXT_DISPLAY_MOD_H
|
||||
|
||||
#undef Fl_Text_Buffer_mod
|
||||
#undef Fl_Text_Display_mod
|
||||
#undef Fl_Text_Editor_mod
|
||||
|
||||
#define Fl_Text_Buffer_mod Fl_Text_Buffer
|
||||
#define Fl_Text_Display_mod Fl_Text_Display
|
||||
#define Fl_Text_Editor_mod Fl_Text_Editor
|
||||
|
||||
#include <FL/Fl_Text_Display.H>
|
||||
|
||||
#endif
|
||||
//
|
||||
// End of "$Id: Fl_Text_Display_mod.H 8306 2011-01-24 17:04:22Z matt $".
|
||||
//
|
||||
|
|
@ -1,110 +1,7 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Editor.H 4288 2005-04-16 00:13:17Z mike $"
|
||||
//
|
||||
// Header file for Fl_Text_Editor class.
|
||||
//
|
||||
// Copyright 2001-2005 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
|
||||
#ifndef FL_TEXT_EDITOR_MOD_H
|
||||
#define FL_TEXT_EDITOR_MOD_H
|
||||
|
||||
#include "Fl_Text_Display_mod.H"
|
||||
|
||||
// key will match in any state
|
||||
#define FL_TEXT_EDITOR_ANY_STATE (-1L)
|
||||
|
||||
class Fl_Text_Editor_mod : public Fl_Text_Display_mod {
|
||||
public:
|
||||
typedef int (*Key_Func)(int key, Fl_Text_Editor_mod* editor);
|
||||
|
||||
struct Key_Binding {
|
||||
int key;
|
||||
int state;
|
||||
Key_Func function;
|
||||
Key_Binding* next;
|
||||
};
|
||||
|
||||
Fl_Text_Editor_mod(int X, int Y, int W, int H, const char* l = 0);
|
||||
~Fl_Text_Editor_mod() { remove_all_key_bindings(); }
|
||||
virtual int handle(int e);
|
||||
void insert_mode(int b) { insert_mode_ = b; }
|
||||
int insert_mode() { return insert_mode_; }
|
||||
|
||||
void add_key_binding(int key, int state, Key_Func f, Key_Binding** list);
|
||||
void add_key_binding(int key, int state, Key_Func f)
|
||||
{ add_key_binding(key, state, f, &key_bindings); }
|
||||
void remove_key_binding(int key, int state, Key_Binding** list);
|
||||
void remove_key_binding(int key, int state)
|
||||
{ remove_key_binding(key, state, &key_bindings); }
|
||||
void remove_all_key_bindings(Key_Binding** list);
|
||||
void remove_all_key_bindings() { remove_all_key_bindings(&key_bindings); }
|
||||
void add_default_key_bindings(Key_Binding** list);
|
||||
Key_Func bound_key_function(int key, int state, Key_Binding* list);
|
||||
Key_Func bound_key_function(int key, int state)
|
||||
{ return bound_key_function(key, state, key_bindings); }
|
||||
void default_key_function(Key_Func f) { default_key_function_ = f; }
|
||||
|
||||
// functions for the built in default bindings
|
||||
static int kf_default(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_ignore(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_backspace(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_enter(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_move(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_shift_move(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_ctrl_move(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_c_s_move(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_home(int, Fl_Text_Editor_mod* e);
|
||||
static int kf_end(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_left(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_up(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_right(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_down(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_page_up(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_page_down(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_insert(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_delete(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_copy(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_cut(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_paste(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_select_all(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_undo(int c, Fl_Text_Editor_mod* e);
|
||||
|
||||
protected:
|
||||
int handle_key();
|
||||
void maybe_do_callback();
|
||||
|
||||
int insert_mode_;
|
||||
Key_Binding* key_bindings;
|
||||
static Key_Binding* global_key_bindings;
|
||||
Key_Func default_key_function_;
|
||||
};
|
||||
#include <config.h>
|
||||
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
# include "Fl_Text_Editor_mod_1_1.H"
|
||||
#elif FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR == 3
|
||||
# include "Fl_Text_Editor_mod_1_3.H"
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Text_Editor.H 4288 2005-04-16 00:13:17Z mike $".
|
||||
//
|
||||
|
||||
|
|
|
|||
110
src/include/Fl_Text_Editor_mod_1_1.H
Normal file
110
src/include/Fl_Text_Editor_mod_1_1.H
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Editor.H 4288 2005-04-16 00:13:17Z mike $"
|
||||
//
|
||||
// Header file for Fl_Text_Editor class.
|
||||
//
|
||||
// Copyright 2001-2005 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
|
||||
#ifndef FL_TEXT_EDITOR_MOD_H
|
||||
#define FL_TEXT_EDITOR_MOD_H
|
||||
|
||||
#include "Fl_Text_Display_mod.H"
|
||||
|
||||
// key will match in any state
|
||||
#define FL_TEXT_EDITOR_ANY_STATE (-1L)
|
||||
|
||||
class Fl_Text_Editor_mod : public Fl_Text_Display_mod {
|
||||
public:
|
||||
typedef int (*Key_Func)(int key, Fl_Text_Editor_mod* editor);
|
||||
|
||||
struct Key_Binding {
|
||||
int key;
|
||||
int state;
|
||||
Key_Func function;
|
||||
Key_Binding* next;
|
||||
};
|
||||
|
||||
Fl_Text_Editor_mod(int X, int Y, int W, int H, const char* l = 0);
|
||||
~Fl_Text_Editor_mod() { remove_all_key_bindings(); }
|
||||
virtual int handle(int e);
|
||||
void insert_mode(int b) { insert_mode_ = b; }
|
||||
int insert_mode() { return insert_mode_; }
|
||||
|
||||
void add_key_binding(int key, int state, Key_Func f, Key_Binding** list);
|
||||
void add_key_binding(int key, int state, Key_Func f)
|
||||
{ add_key_binding(key, state, f, &key_bindings); }
|
||||
void remove_key_binding(int key, int state, Key_Binding** list);
|
||||
void remove_key_binding(int key, int state)
|
||||
{ remove_key_binding(key, state, &key_bindings); }
|
||||
void remove_all_key_bindings(Key_Binding** list);
|
||||
void remove_all_key_bindings() { remove_all_key_bindings(&key_bindings); }
|
||||
void add_default_key_bindings(Key_Binding** list);
|
||||
Key_Func bound_key_function(int key, int state, Key_Binding* list);
|
||||
Key_Func bound_key_function(int key, int state)
|
||||
{ return bound_key_function(key, state, key_bindings); }
|
||||
void default_key_function(Key_Func f) { default_key_function_ = f; }
|
||||
|
||||
// functions for the built in default bindings
|
||||
static int kf_default(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_ignore(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_backspace(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_enter(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_move(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_shift_move(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_ctrl_move(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_c_s_move(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_home(int, Fl_Text_Editor_mod* e);
|
||||
static int kf_end(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_left(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_up(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_right(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_down(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_page_up(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_page_down(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_insert(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_delete(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_copy(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_cut(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_paste(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_select_all(int c, Fl_Text_Editor_mod* e);
|
||||
static int kf_undo(int c, Fl_Text_Editor_mod* e);
|
||||
|
||||
protected:
|
||||
int handle_key();
|
||||
void maybe_do_callback();
|
||||
|
||||
int insert_mode_;
|
||||
Key_Binding* key_bindings;
|
||||
static Key_Binding* global_key_bindings;
|
||||
Key_Func default_key_function_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Text_Editor.H 4288 2005-04-16 00:13:17Z mike $".
|
||||
//
|
||||
|
||||
51
src/include/Fl_Text_Editor_mod_1_3.H
Normal file
51
src/include/Fl_Text_Editor_mod_1_3.H
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Editor_mod.H 7903 2010-11-28 21:06:39Z matt $"
|
||||
//
|
||||
// Header file for Fl_Text_Editor_mod class.
|
||||
//
|
||||
// Copyright 2001-2010 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
/* \file
|
||||
Fl_Text_Editor_mod widget . */
|
||||
|
||||
|
||||
#ifndef FL_TEXT_EDITOR_MOD_H
|
||||
#define FL_TEXT_EDITOR_MOD_H
|
||||
|
||||
#undef Fl_Text_Buffer_mod
|
||||
#undef Fl_Text_Display_mod
|
||||
#undef Fl_Text_Editor_mod
|
||||
|
||||
#define Fl_Text_Buffer_mod Fl_Text_Buffer
|
||||
#define Fl_Text_Display_mod Fl_Text_Display
|
||||
#define Fl_Text_Editor_mod Fl_Text_Editor
|
||||
|
||||
#include <FL/Fl_Text_Editor.H>
|
||||
|
||||
#endif
|
||||
//
|
||||
// End of "$Id: Fl_Text_Editor_mod.H 7903 2010-11-28 21:06:39Z matt $".
|
||||
//
|
||||
|
||||
45
src/include/dirent-check.h
Normal file
45
src/include/dirent-check.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// =====================================================================
|
||||
//
|
||||
// dirent-check.h
|
||||
//
|
||||
// Author: Dave Freese, W1HKJ
|
||||
// Copyright: 2010
|
||||
//
|
||||
// This software is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is
|
||||
// copyright under the GNU General Public License.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the program; if not, write to the Free Software
|
||||
// Foundation, Inc.
|
||||
// 59 Temple Place, Suite 330
|
||||
// Boston, MA 02111-1307 USA
|
||||
//
|
||||
// =====================================================================
|
||||
//
|
||||
// required for successfull compile using either Fltk-1.1.10 or 1.3.0
|
||||
//
|
||||
// =====================================================================
|
||||
|
||||
#ifndef DIRENT_CHECK_H
|
||||
#define DIRENT_CHECK_H
|
||||
|
||||
// this tests depends on a modified FL/filename.H in the Fltk-1.3.0
|
||||
// change
|
||||
//# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
||||
// to
|
||||
//# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) && !defined(__WOE32__)
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
# undef dirent
|
||||
# include <dirent.h>
|
||||
# else
|
||||
# include <dirent.h>
|
||||
# endif
|
||||
#else
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,12 +1,18 @@
|
|||
#ifndef FILESELECT_H
|
||||
#define FILESELECT_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
//#ifdef __WIN32__
|
||||
//# define FSEL_THREAD 1
|
||||
//#endif
|
||||
#define FSEL_THREAD 0
|
||||
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
class Fl_Native_File_Chooser;
|
||||
#else
|
||||
#include <FL/Fl_Native_File_Chooser.H>
|
||||
#endif
|
||||
|
||||
class FSEL
|
||||
{
|
||||
|
|
|
|||
113
src/include/flstring.h
Normal file
113
src/include/flstring.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* "$Id: flstring.h 4660 2005-11-27 14:45:48Z mike $"
|
||||
*
|
||||
* Common string header file for the Fast Light Tool Kit (FLTK).
|
||||
*
|
||||
* Copyright 1998-2005 by Bill Spitzak and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems on the following page:
|
||||
*
|
||||
* http://www.fltk.org/str.php
|
||||
*/
|
||||
|
||||
#ifndef flstring_h
|
||||
# define flstring_h
|
||||
|
||||
# include <FL/Fl_Export.H>
|
||||
# include <config.h>
|
||||
# include <stdio.h>
|
||||
# include <stdarg.h>
|
||||
# include <string.h>
|
||||
# ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
# endif /* HAVE_STRINGS_H */
|
||||
# include <ctype.h>
|
||||
|
||||
/*
|
||||
* Apparently Unixware defines "index" to strchr (!) rather than
|
||||
* providing a proper entry point or not providing the (obsolete)
|
||||
* BSD function. Make sure index is not defined...
|
||||
*/
|
||||
|
||||
# ifdef index
|
||||
# undef index
|
||||
# endif /* index */
|
||||
|
||||
# if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define strcasecmp(s,t) _stricmp((s), (t))
|
||||
# define strncasecmp(s,t,n) _strnicmp((s), (t), (n))
|
||||
// Visual C++ 2005 incorrectly displays a warning about the use of POSIX APIs
|
||||
// on Windows, which is supposed to be POSIX compliant... Some of these functions
|
||||
// are also defined in ISO C99...
|
||||
# define strdup _strdup
|
||||
# define unlink _unlink
|
||||
# elif defined(__EMX__)
|
||||
# define strcasecmp(s,t) stricmp((s), (t))
|
||||
# define strncasecmp(s,t,n) strnicmp((s), (t), (n))
|
||||
# endif /* WIN32 */
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* MetroWerks' CodeWarrior put thes "non-standard" functions in
|
||||
* <extras.h> which unfortunatly does not play well otherwise
|
||||
* when included - to be resolved...
|
||||
*/
|
||||
|
||||
# if defined(__APPLE__) && defined(__MWERKS__) && defined(_MSL_USING_MW_C_HEADERS)
|
||||
int strcasecmp(const char*,const char*);
|
||||
int strncasecmp(const char*,const char*,int);
|
||||
char *strdup(const char*);
|
||||
# endif
|
||||
|
||||
FL_EXPORT extern int fl_snprintf(char *, size_t, const char *, ...);
|
||||
# if !HAVE_SNPRINTF
|
||||
# define snprintf fl_snprintf
|
||||
# endif /* !HAVE_SNPRINTF */
|
||||
|
||||
FL_EXPORT extern int fl_vsnprintf(char *, size_t, const char *, va_list ap);
|
||||
# if !HAVE_VSNPRINTF
|
||||
# define vsnprintf fl_vsnprintf
|
||||
# endif /* !HAVE_VSNPRINTF */
|
||||
|
||||
/*
|
||||
* strlcpy() and strlcat() are some really useful BSD string functions
|
||||
* that work the way strncpy() and strncat() *should* have worked.
|
||||
*/
|
||||
|
||||
FL_EXPORT extern size_t fl_strlcat(char *, const char *, size_t);
|
||||
# if !HAVE_STRLCAT
|
||||
# define strlcat fl_strlcat
|
||||
# endif /* !HAVE_STRLCAT */
|
||||
|
||||
FL_EXPORT extern size_t fl_strlcpy(char *, const char *, size_t);
|
||||
# if !HAVE_STRLCPY
|
||||
# define strlcpy fl_strlcpy
|
||||
# endif /* !HAVE_STRLCPY */
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif /* __cplusplus */
|
||||
#endif /* !flstring_h */
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id: flstring.h 4660 2005-11-27 14:45:48Z mike $".
|
||||
*/
|
||||
|
|
@ -690,7 +690,7 @@ static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
|
|||
p->needFlush = 0;
|
||||
}
|
||||
|
||||
void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
|
||||
void LzmaDec_InitDicAndState(CLzmaDec *p, int initDic, int initState)
|
||||
{
|
||||
p->needFlush = 1;
|
||||
p->remainLen = 0;
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ typedef struct _CLzmaEnc
|
|||
void *matchFinderObj;
|
||||
|
||||
#ifdef COMPRESS_MF_MT
|
||||
Bool mtMode;
|
||||
int mtMode;
|
||||
CMatchFinderMt matchFinderMt;
|
||||
#endif
|
||||
|
||||
|
|
@ -337,15 +337,15 @@ typedef struct _CLzmaEnc
|
|||
|
||||
unsigned lclp;
|
||||
|
||||
Bool fastMode;
|
||||
int fastMode;
|
||||
|
||||
CRangeEnc rc;
|
||||
|
||||
Bool writeEndMark;
|
||||
int writeEndMark;
|
||||
UInt64 nowPos64;
|
||||
UInt32 matchPriceCount;
|
||||
Bool finished;
|
||||
Bool multiThread;
|
||||
int finished;
|
||||
int multiThread;
|
||||
|
||||
SRes result;
|
||||
UInt32 dictSize;
|
||||
|
|
@ -810,7 +810,7 @@ static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt3
|
|||
LenPriceEnc_UpdateTable(p, posState, ProbPrices);
|
||||
}
|
||||
|
||||
static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices)
|
||||
static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, int updatePrice, UInt32 *ProbPrices)
|
||||
{
|
||||
LenEnc_Encode(&p->p, rc, symbol, posState);
|
||||
if (updatePrice)
|
||||
|
|
@ -1146,7 +1146,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
|
|||
{
|
||||
UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
|
||||
UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;
|
||||
Bool nextIsChar;
|
||||
int nextIsChar;
|
||||
Byte curByte, matchByte;
|
||||
const Byte *data;
|
||||
COptimal *curOpt;
|
||||
|
|
@ -1751,7 +1751,7 @@ void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig)
|
|||
alloc->Free(alloc, p);
|
||||
}
|
||||
|
||||
static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize)
|
||||
static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, int useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize)
|
||||
{
|
||||
UInt32 nowPos32, startPos32;
|
||||
if (p->inStream != 0)
|
||||
|
|
@ -1919,7 +1919,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
|
|||
static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||
{
|
||||
UInt32 beforeSize = kNumOpts;
|
||||
Bool btMode;
|
||||
int btMode;
|
||||
if (!RangeEnc_Alloc(&p->rc, alloc))
|
||||
return SZ_ERROR_MEM;
|
||||
btMode = (p->matchFinderBase.btMode != 0);
|
||||
|
|
@ -2106,7 +2106,7 @@ typedef struct _CSeqOutStreamBuf
|
|||
ISeqOutStream funcTable;
|
||||
Byte *data;
|
||||
SizeT rem;
|
||||
Bool overflow;
|
||||
int overflow;
|
||||
} CSeqOutStreamBuf;
|
||||
|
||||
static size_t MyWrite(void *pp, const void *data, size_t size)
|
||||
|
|
@ -2136,7 +2136,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
|
|||
return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
|
||||
}
|
||||
|
||||
SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
||||
SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, int reInit,
|
||||
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
|
||||
{
|
||||
CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ typedef UInt32 SizeT;
|
|||
typedef size_t SizeT;
|
||||
#endif
|
||||
|
||||
typedef int Bool;
|
||||
//typedef int Bool;
|
||||
#define True 1
|
||||
#define False 0
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -65,10 +65,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,7 @@
|
|||
#endif
|
||||
|
||||
#include <FL/filename.H>
|
||||
#ifdef __MINGW32__
|
||||
# undef dirent
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include "dirent-check.h"
|
||||
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
|
|
|||
|
|
@ -329,19 +329,19 @@ string ics_xml_t2;
|
|||
string ics_xml_s2;
|
||||
string ics_xml_p4;
|
||||
|
||||
enum PARSE_ICS_MODE {TO, FM, RECIP, SENDER, SUBJ, MSG, PREP, REPLY} ics_pmode;
|
||||
enum PARSE_ICS_MODE {HICS_TO, HICS_FM, HICS_RECIP, HICS_SENDER, HICS_SUBJ, HICS_MSG, HICS_PREP, HICS_REPLY} ics_pmode;
|
||||
|
||||
|
||||
void parse_ics_name(size_t &p0, string xml)
|
||||
{
|
||||
string contents = get_element(p0, xml).c_str();
|
||||
switch (ics_pmode) {
|
||||
case TO:
|
||||
case RECIP: ics_xml_to = contents; break;
|
||||
case FM:
|
||||
case SENDER: ics_xml_fm = contents; break;
|
||||
case MSG: xml_s1 = contents; break;
|
||||
case REPLY: ics_xml_s2 = contents; break;
|
||||
case HICS_TO:
|
||||
case HICS_RECIP: ics_xml_to = contents; break;
|
||||
case HICS_FM:
|
||||
case HICS_SENDER: ics_xml_fm = contents; break;
|
||||
case HICS_MSG: xml_s1 = contents; break;
|
||||
case HICS_REPLY: ics_xml_s2 = contents; break;
|
||||
default : ;
|
||||
}
|
||||
p0 = next_tag(p0 + 1, xml);
|
||||
|
|
@ -352,12 +352,12 @@ void parse_ics_position(size_t &p0, string xml)
|
|||
{
|
||||
string contents = get_element(p0, xml).c_str();
|
||||
switch (ics_pmode) {
|
||||
case TO:
|
||||
case RECIP: ics_xml_p1 = contents; break;
|
||||
case FM:
|
||||
case SENDER: ics_xml_p2 = contents; break;
|
||||
case MSG: xml_p3 = contents; break;
|
||||
case REPLY: ics_xml_p4 = contents; break;
|
||||
case HICS_TO:
|
||||
case HICS_RECIP: ics_xml_p1 = contents; break;
|
||||
case HICS_FM:
|
||||
case HICS_SENDER: ics_xml_p2 = contents; break;
|
||||
case HICS_MSG: xml_p3 = contents; break;
|
||||
case HICS_REPLY: ics_xml_p4 = contents; break;
|
||||
default : ;
|
||||
}
|
||||
p0 = next_tag(p0 + 1, xml);
|
||||
|
|
@ -373,11 +373,11 @@ void parse_ics_para(size_t &p0, string xml)
|
|||
{
|
||||
string contents = get_element(p0, xml).c_str();
|
||||
switch (ics_pmode) {
|
||||
case MSG:
|
||||
case HICS_MSG:
|
||||
fm_xml(contents);
|
||||
ics_xml_msg.append(contents).append("\n");
|
||||
break;
|
||||
case REPLY:
|
||||
case HICS_REPLY:
|
||||
fm_xml(contents);
|
||||
xml_reply.append(contents).append("\n");
|
||||
break;
|
||||
|
|
@ -390,12 +390,12 @@ void parse_ics_date(size_t &p0, string xml)
|
|||
{
|
||||
string contents = get_element(p0, xml).c_str();
|
||||
switch (ics_pmode) {
|
||||
case TO:
|
||||
case FM:
|
||||
case SENDER:
|
||||
case MSG:
|
||||
case RECIP: ics_xml_d1 = contents; break;
|
||||
case REPLY: ics_xml_d2 =contents; break;
|
||||
case HICS_TO:
|
||||
case HICS_FM:
|
||||
case HICS_SENDER:
|
||||
case HICS_MSG:
|
||||
case HICS_RECIP: ics_xml_d1 = contents; break;
|
||||
case HICS_REPLY: ics_xml_d2 =contents; break;
|
||||
default : ;
|
||||
}
|
||||
p0 = next_tag(p0 + 1, xml);
|
||||
|
|
@ -405,11 +405,11 @@ void parse_ics_time(size_t &p0, string xml)
|
|||
{
|
||||
string contents = get_element(p0, xml).c_str();
|
||||
switch (ics_pmode) {
|
||||
case TO:
|
||||
case FM:
|
||||
case SENDER:
|
||||
case RECIP: ics_xml_t1 = contents; break;
|
||||
case REPLY: ics_xml_t2 =contents; break;
|
||||
case HICS_TO:
|
||||
case HICS_FM:
|
||||
case HICS_SENDER:
|
||||
case HICS_RECIP: ics_xml_t1 = contents; break;
|
||||
case HICS_REPLY: ics_xml_t2 =contents; break;
|
||||
default : ;
|
||||
}
|
||||
p0 = next_tag(p0 + 1, xml);
|
||||
|
|
@ -422,7 +422,7 @@ void parse_ics_exercise(size_t &p0, string xml)
|
|||
|
||||
void parse_ics_recipient(size_t &p0, string xml)
|
||||
{
|
||||
ics_pmode = RECIP;
|
||||
ics_pmode = HICS_RECIP;
|
||||
string recip = get_element(p0, xml);
|
||||
parse_ics(recip);
|
||||
p0 = tag_end(p0, xml);
|
||||
|
|
@ -431,7 +431,7 @@ void parse_ics_recipient(size_t &p0, string xml)
|
|||
|
||||
void parse_ics_sender(size_t &p0, string xml)
|
||||
{
|
||||
ics_pmode = SENDER;
|
||||
ics_pmode = HICS_SENDER;
|
||||
string sender = get_element(p0, xml);
|
||||
parse_ics(sender);
|
||||
p0 = tag_end(p0, xml);
|
||||
|
|
@ -448,8 +448,8 @@ void parse_ics_signature(size_t &p0, string xml)
|
|||
|
||||
void parse_ics_body(size_t &p0, string xml)
|
||||
{
|
||||
if (ics_pmode == TO || ics_pmode == FM || ics_pmode == RECIP || ics_pmode == SENDER)
|
||||
ics_pmode = MSG;
|
||||
if (ics_pmode == HICS_TO || ics_pmode == HICS_FM || ics_pmode == HICS_RECIP || ics_pmode == HICS_SENDER)
|
||||
ics_pmode = HICS_MSG;
|
||||
string body = get_element(p0, xml);
|
||||
parse_ics(body);
|
||||
p0 = tag_end(p0, xml);
|
||||
|
|
@ -468,7 +468,7 @@ void parse_ics_id(size_t &p0, string xml)
|
|||
|
||||
void parse_ics_reply(size_t &p0, string xml)
|
||||
{
|
||||
ics_pmode = REPLY;
|
||||
ics_pmode = HICS_REPLY;
|
||||
string reply = get_element(p0, xml);
|
||||
parse_ics(reply);
|
||||
p0 = tag_end(p0, xml);
|
||||
|
|
@ -477,7 +477,7 @@ void parse_ics_reply(size_t &p0, string xml)
|
|||
|
||||
void parse_ics_message(size_t &p0, string xml)
|
||||
{
|
||||
ics_pmode = TO;
|
||||
ics_pmode = HICS_TO;
|
||||
string message;
|
||||
message = get_element(p0, xml);
|
||||
parse_ics(message);
|
||||
|
|
@ -587,7 +587,7 @@ bool qform_ics_import(string fname)
|
|||
retval = fread (buff, filesize, 1, xmlfile);
|
||||
fclose (xmlfile);
|
||||
|
||||
ics_pmode = TO;
|
||||
ics_pmode = HICS_TO;
|
||||
clear_ics_xml();
|
||||
|
||||
parse_ics(buff);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// Copyright (C) 2007-2009
|
||||
// Stelios Bounanos, M0GLD
|
||||
//
|
||||
// Copyright (C) 2008
|
||||
// Copyright (C) 2008-2009
|
||||
// Dave Freese, W1HKJ
|
||||
//
|
||||
// This file is part of fldigi.
|
||||
|
|
@ -23,8 +23,7 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "config.h"
|
||||
#include "flmsg_config.h"
|
||||
#include <config.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
|
@ -37,20 +36,24 @@
|
|||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <FL/Fl_Tooltip.H>
|
||||
|
||||
//#include "flmisc.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "fileselect.h"
|
||||
//#include "font_browser.h"
|
||||
//#include "ascii.h"
|
||||
#include "icons.h"
|
||||
#include "gettext.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "FTextView.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
# define Fl_Text_Buffer_mod Fl_Text_Buffer
|
||||
#endif
|
||||
|
||||
/// FTextBase constructor.
|
||||
/// Word wrapping is enabled by default at column 80, but see \c reset_wrap_col.
|
||||
|
|
@ -69,14 +72,16 @@ FTextBase::FTextBase(int x, int y, int w, int h, const char *l)
|
|||
textsize(FL_NORMAL_SIZE);
|
||||
textcolor(FL_FOREGROUND_COLOR);
|
||||
|
||||
tbuf = new Fl_Text_Buffer;
|
||||
sbuf = new Fl_Text_Buffer;
|
||||
tbuf = new Fl_Text_Buffer_mod;
|
||||
sbuf = new Fl_Text_Buffer_mod;
|
||||
|
||||
cursor_style(Fl_Text_Editor_mod::NORMAL_CURSOR);
|
||||
buffer(tbuf);
|
||||
highlight_data(sbuf, styles, NATTR, FTEXT_DEF, 0, 0);
|
||||
cursor_style(Fl_Text_Editor_mod::NORMAL_CURSOR);
|
||||
|
||||
wrap_mode(wrap, wrap_col);
|
||||
restore_wrap = wrap;
|
||||
// wrap_restore = true;
|
||||
|
||||
// Do we want narrower scrollbars? The default width is 16.
|
||||
// scrollbar_width((int)floor(scrollbar_width() * 3.0/4.0));
|
||||
|
|
@ -84,6 +89,13 @@ FTextBase::FTextBase(int x, int y, int w, int h, const char *l)
|
|||
reset_styles(SET_FONT | SET_SIZE | SET_COLOR);
|
||||
}
|
||||
|
||||
void FTextBase::clear()
|
||||
{
|
||||
tbuf->text("");
|
||||
sbuf->text("");
|
||||
set_word_wrap(restore_wrap);
|
||||
}
|
||||
|
||||
int FTextBase::handle(int event)
|
||||
{
|
||||
if (event == FL_MOUSEWHEEL && !Fl::event_inside(this))
|
||||
|
|
@ -99,6 +111,37 @@ int FTextBase::handle(int event)
|
|||
return Fl_Text_Editor_mod::handle(event);
|
||||
}
|
||||
|
||||
/// @see FTextRX::add
|
||||
///
|
||||
/// @param s
|
||||
/// @param attr
|
||||
///
|
||||
void FTextBase::add(const char *s, int attr)
|
||||
{
|
||||
// handle the text attribute first
|
||||
int n = strlen(s);
|
||||
char a[n + 1];
|
||||
memset(a, FTEXT_DEF + attr, n);
|
||||
a[n] = '\0';
|
||||
sbuf->replace(insert_position(), insert_position() + n, a);
|
||||
|
||||
insert(s);
|
||||
}
|
||||
|
||||
/// @see FTextBase::add
|
||||
///
|
||||
/// @param s
|
||||
/// @param attr
|
||||
///
|
||||
void FTextBase::add(unsigned char c, int attr)
|
||||
{
|
||||
char s[] = { FTEXT_DEF + attr, '\0' };
|
||||
sbuf->replace(insert_position(), insert_position() + 1, s);
|
||||
|
||||
s[0] = c;
|
||||
insert(s);
|
||||
}
|
||||
|
||||
void FTextBase::set_word_wrap(bool b)
|
||||
{
|
||||
wrap_mode((wrap = b), wrap_col);
|
||||
|
|
@ -152,6 +195,8 @@ void FTextBase::resize(int X, int Y, int W, int H)
|
|||
if (need_wrap_reset)
|
||||
reset_wrap_col();
|
||||
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR == 3
|
||||
#else
|
||||
if (need_margin_reset && textsize() > 0) {
|
||||
TOP_MARGIN = DEFAULT_TOP_MARGIN;
|
||||
int r = H - Fl::box_dh(box()) - TOP_MARGIN - BOTTOM_MARGIN;
|
||||
|
|
@ -160,7 +205,7 @@ void FTextBase::resize(int X, int Y, int W, int H)
|
|||
if (r %= textsize())
|
||||
TOP_MARGIN += r;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (scroll_hint) {
|
||||
mTopLineNumHint = mNBufferLines;
|
||||
mHorizOffsetHint = 0;
|
||||
|
|
@ -238,6 +283,9 @@ void FTextBase::set_style(int attr, Fl_Font f, int s, Fl_Color c, int set)
|
|||
}
|
||||
|
||||
/// Reads a file and inserts its contents.
|
||||
/// change all occurrences of ^ to ^^ to prevent get_tx_char from
|
||||
/// treating the carat as a control sequence, ie: ^r ^R ^t ^T ^L ^C
|
||||
/// get_tx_char passes ^^ as a single ^
|
||||
///
|
||||
/// @return 0 on success, -1 on error
|
||||
int FTextBase::readFile(const char* fn)
|
||||
|
|
@ -249,41 +297,47 @@ int FTextBase::readFile(const char* fn)
|
|||
|
||||
#ifdef __WOE32__
|
||||
FILE* tfile = fopen(fn, "rt");
|
||||
#else
|
||||
FILE* tfile = fopen(fn, "r");
|
||||
#endif
|
||||
if (!tfile)
|
||||
return -1;
|
||||
char buf[BUFSIZ+1];
|
||||
std::string newbuf;
|
||||
size_t p;
|
||||
memset(buf, 0, BUFSIZ+1);
|
||||
if (pos == tbuf->length()) { // optimise for append
|
||||
while (fgets(buf, sizeof(buf), tfile))
|
||||
tbuf->append(buf);
|
||||
while (fgets(buf, sizeof(buf), tfile)) {
|
||||
newbuf = buf;
|
||||
p = 0;
|
||||
while ((p = newbuf.find('^',p)) != string::npos) {
|
||||
newbuf.insert(p, "^");
|
||||
p += 2;
|
||||
}
|
||||
tbuf->append(newbuf.c_str());
|
||||
memset(buf, 0, BUFSIZ+1);
|
||||
}
|
||||
if (ferror(tfile))
|
||||
ret = -1;
|
||||
pos = tbuf->length();
|
||||
}
|
||||
else {
|
||||
while (fgets(buf, sizeof(buf), tfile)) {
|
||||
tbuf->insert(pos, buf);
|
||||
newbuf = buf;
|
||||
p = 0;
|
||||
while ((p = newbuf.find('^',p)) != string::npos) {
|
||||
newbuf.insert(p, "^");
|
||||
p += 2;
|
||||
}
|
||||
tbuf->insert(pos, newbuf.c_str());
|
||||
pos += strlen(buf);
|
||||
memset(buf, 0, BUFSIZ+1);
|
||||
}
|
||||
if (ferror(tfile))
|
||||
ret = -1;
|
||||
}
|
||||
fclose(tfile);
|
||||
#else
|
||||
if (pos == tbuf->length()) { // optimise for append
|
||||
if (tbuf->appendfile(fn) != 0)
|
||||
ret = -1;
|
||||
pos = tbuf->length();
|
||||
}
|
||||
else {
|
||||
if (tbuf->insertfile(fn, pos) == 0) {
|
||||
struct stat st;
|
||||
if (stat(fn, &st) == 0)
|
||||
pos += st.st_size;
|
||||
}
|
||||
else
|
||||
ret = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
insert_position(pos);
|
||||
show_insert_position();
|
||||
|
||||
|
|
@ -332,7 +386,11 @@ void FTextBase::saveFile(void)
|
|||
///
|
||||
/// @return The selection, or the word text at (x,y). <b>Must be freed by the caller</b>.
|
||||
///
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
char* FTextBase::get_word(int x, int y, const char* nwchars, bool ontext)
|
||||
#else
|
||||
char* FTextBase::get_word(int x, int y, bool ontext)
|
||||
#endif
|
||||
{
|
||||
int p = xy_to_position(x + this->x(), y + this->y(), Fl_Text_Display_mod::CURSOR_POS);
|
||||
int start, end;
|
||||
|
|
@ -344,12 +402,19 @@ char* FTextBase::get_word(int x, int y, bool ontext)
|
|||
return tbuf->selection_text();
|
||||
}
|
||||
|
||||
if (!tbuf->findchars_backward(p, " \t\n", &start))
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR == 3
|
||||
start = tbuf->word_start(p);
|
||||
end = tbuf->word_end(p);
|
||||
#else
|
||||
string nonword = nwchars;
|
||||
nonword.append(" \t\n");
|
||||
if (!tbuf->findchars_backward(p, nonword.c_str(), &start))
|
||||
start = 0;
|
||||
else
|
||||
start++;
|
||||
if (!tbuf->findchars_forward(p, " .,;|\t\n", &end))
|
||||
if (!tbuf->findchars_forward(p, nonword.c_str(), &end))
|
||||
end = tbuf->length();
|
||||
#endif
|
||||
|
||||
if (ontext && (p < start || p >= end))
|
||||
return 0;
|
||||
|
|
@ -421,11 +486,11 @@ void FTextBase::reset_styles(int set)
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
Fl_Menu_Item FTextView::menu[] = {
|
||||
{ make_icon_label(_("&Copy"), edit_copy_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("C&lear"), edit_clear_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Copy"), edit_copy_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Clear"), edit_clear_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Select All"), edit_select_all_icon), 0, 0, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Save &as..."), save_as_icon), 0, 0, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL },
|
||||
{ _("Word &wrap"), 0, 0, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL },
|
||||
{ make_icon_label(_("Save as..."), save_as_icon), 0, 0, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL },
|
||||
{ _("Word wrap"), 0, 0, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
|
@ -452,53 +517,6 @@ FTextView::FTextView(int x, int y, int w, int h, const char *l)
|
|||
init_context_menu();
|
||||
}
|
||||
|
||||
/// Adds a char to the buffer
|
||||
///
|
||||
/// @param c The character
|
||||
/// @param attr The attribute (@see enum text_attr_e); RECV if omitted.
|
||||
///
|
||||
void FTextView::add(unsigned char c, int attr)
|
||||
{
|
||||
if (c == '\r')
|
||||
return;
|
||||
|
||||
// The user may have moved the cursor by selecting text or
|
||||
// scrolling. Place it at the end of the buffer.
|
||||
if (mCursorPos != tbuf->length())
|
||||
insert_position(tbuf->length());
|
||||
|
||||
switch (c) {
|
||||
case '\b':
|
||||
// we don't call kf_backspace because it kills selected text
|
||||
tbuf->remove(tbuf->length() - 1, tbuf->length());
|
||||
sbuf->remove(sbuf->length() - 1, sbuf->length());
|
||||
break;
|
||||
case '\n':
|
||||
// maintain the scrollback limit, if we have one
|
||||
if (max_lines > 0 && tbuf->count_lines(0, tbuf->length()) >= max_lines) {
|
||||
int le = tbuf->line_end(0) + 1; // plus 1 for the newline
|
||||
tbuf->remove(0, le);
|
||||
sbuf->remove(0, le);
|
||||
}
|
||||
// fall-through
|
||||
default:
|
||||
char s[] = { '\0', '\0', FTEXT_DEF + attr, '\0' };
|
||||
const char *cp;
|
||||
|
||||
// if ((c < ' ' || c == 127) && attr != CTRL) // look it up
|
||||
// cp = ascii[(unsigned char)c];
|
||||
// else { // insert verbatim
|
||||
s[0] = c;
|
||||
cp = &s[0];
|
||||
// }
|
||||
|
||||
for (int i = 0; cp[i]; ++i)
|
||||
sbuf->append(s + 2);
|
||||
insert(cp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles fltk events for this widget.
|
||||
|
||||
/// We only care about mouse presses (to display the popup menu and prevent
|
||||
|
|
@ -574,6 +592,7 @@ void FTextView::menu_cb(size_t item)
|
|||
break;
|
||||
case VIEW_MENU_WRAP:
|
||||
set_word_wrap(!wrap);
|
||||
restore_wrap = wrap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -631,12 +650,12 @@ loop:
|
|||
|
||||
|
||||
Fl_Menu_Item FTextEdit::menu[] = {
|
||||
{ make_icon_label(_("Cu&t"), edit_cut_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("&Copy"), edit_copy_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("&Paste"), edit_paste_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("C&lear"), edit_clear_icon), 0, 0, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Insert &file..."), file_open_icon), 0, 0, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL },
|
||||
{ _("Word &wrap"), 0, 0, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL } ,
|
||||
{ make_icon_label(_("Cut"), edit_cut_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Copy"), edit_copy_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Paste"), edit_paste_icon), 0, 0, 0, 0, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Clear"), edit_clear_icon), 0, 0, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL },
|
||||
{ make_icon_label(_("Insert file..."), file_open_icon), 0, 0, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL },
|
||||
{ _("Word wrap"), 0, 0, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL } ,
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
|
@ -700,37 +719,6 @@ int FTextEdit::handle(int event)
|
|||
return FTextBase::handle(event);
|
||||
}
|
||||
|
||||
/// @see FTextView::add
|
||||
///
|
||||
/// @param s
|
||||
/// @param attr
|
||||
///
|
||||
void FTextEdit::add(const char *s, int attr)
|
||||
{
|
||||
// handle the text attribute first
|
||||
int n = strlen(s);
|
||||
char a[n + 1];
|
||||
memset(a, FTEXT_DEF + attr, n);
|
||||
a[n] = '\0';
|
||||
sbuf->replace(insert_position(), insert_position() + n, a);
|
||||
|
||||
insert(s);
|
||||
}
|
||||
|
||||
/// @see FTextEdit::add
|
||||
///
|
||||
/// @param s
|
||||
/// @param attr
|
||||
///
|
||||
void FTextEdit::add(unsigned char c, int attr)
|
||||
{
|
||||
char s[] = { FTEXT_DEF + attr, '\0' };
|
||||
sbuf->replace(insert_position(), insert_position() + 1, s);
|
||||
|
||||
s[0] = c;
|
||||
insert(s);
|
||||
}
|
||||
|
||||
/// Handles keyboard events to override Fl_Text_Editor_mod's handling of some
|
||||
/// keystrokes.
|
||||
///
|
||||
|
|
@ -742,14 +730,11 @@ int FTextEdit::handle_key(int key)
|
|||
{
|
||||
// read ctl-ddd, where d is a digit, as ascii characters (in base 10)
|
||||
// and insert verbatim; e.g. ctl-001 inserts a <soh>
|
||||
if ((Fl::event_state() & FL_CTRL) == FL_CTRL) {
|
||||
if (key >= '0' && key <= '9')
|
||||
return handle_key_ascii(key - '0');
|
||||
if (key >= (FL_KP + '0') && key <= (FL_KP + '9'))
|
||||
return handle_key_ascii(key - FL_KP - '0');
|
||||
}
|
||||
if (Fl::event_state() & FL_CTRL && (isdigit(key) || isdigit(key - FL_KP)))
|
||||
return handle_key_ascii(key);
|
||||
ascii_cnt = 0; // restart the numeric keypad entries.
|
||||
ascii_chr = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -763,6 +748,9 @@ int FTextEdit::handle_key(int key)
|
|||
///
|
||||
int FTextEdit::handle_key_ascii(int key)
|
||||
{
|
||||
if (key >= FL_KP)
|
||||
key -= FL_KP;
|
||||
key -= '0';
|
||||
ascii_cnt++;
|
||||
for (int i = 0; i < 3 - ascii_cnt; i++)
|
||||
key *= 10;
|
||||
|
|
@ -801,6 +789,9 @@ int FTextEdit::handle_dnd_drag(int pos)
|
|||
/// @return 1 or FTextBase::handle(FL_PASTE)
|
||||
int FTextEdit::handle_dnd_drop(void)
|
||||
{
|
||||
restore_wrap = wrap;
|
||||
set_word_wrap(false);
|
||||
|
||||
if (Fl::event_shift())
|
||||
return FTextBase::handle(FL_PASTE);
|
||||
|
||||
|
|
@ -878,6 +869,7 @@ void FTextEdit::menu_cb(size_t item)
|
|||
break;
|
||||
case EDIT_MENU_WRAP:
|
||||
set_word_wrap(!wrap);
|
||||
restore_wrap = wrap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@
|
|||
// USA.
|
||||
//
|
||||
|
||||
//#include <config.h>
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
|
||||
// Use Windows' chooser
|
||||
#if defined(__WIN32__) || defined(__CYGWIN__)
|
||||
|
|
@ -36,3 +39,4 @@
|
|||
#include "Fl_Native_File_Chooser_FLTK.cxx"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@
|
|||
// o When doing 'open file', only dir is preset, not filename.
|
||||
// Possibly 'preset_file' could be used to select the filename.
|
||||
//
|
||||
|
||||
#include <FL/Fl_File_Icon.H>
|
||||
|
||||
#include "flnfc_common.cxx" // strnew/strfree/strapp/chrcat
|
||||
|
||||
#define FLTK1
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@
|
|||
//
|
||||
|
||||
#include <stdio.h> // debugging
|
||||
#include <FL/Fl_File_Icon.H>
|
||||
|
||||
#include "flnfc_common.cxx" // strnew/strfree/strapp/chrcat
|
||||
|
||||
#define FLTK1
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
3267
src/widgets/Fl_Text_Display_mod_1_1.cxx
Normal file
3267
src/widgets/Fl_Text_Display_mod_1_1.cxx
Normal file
File diff suppressed because it is too large
Load diff
33
src/widgets/Fl_Text_Display_mod_1_3.cxx
Normal file
33
src/widgets/Fl_Text_Display_mod_1_3.cxx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Display_mod.cxx 8808 2011-06-16 13:31:25Z manolo $"
|
||||
//
|
||||
// Copyright 2001-2010 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
// TODO: rendering of the "optional hyphen"
|
||||
// TODO: make line numbering work again
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Text_Display_mod.cxx 8808 2011-06-16 13:31:25Z manolo $".
|
||||
//
|
||||
|
|
@ -1,501 +1,7 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Editor.cxx 5671 2007-02-08 07:58:47Z matt $"
|
||||
//
|
||||
// Copyright 2001-2006 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include "flstring.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include "Fl_Text_Editor_mod.H"
|
||||
#include <FL/fl_ask.H>
|
||||
|
||||
|
||||
|
||||
Fl_Text_Editor_mod::Fl_Text_Editor_mod(int X, int Y, int W, int H, const char* l)
|
||||
: Fl_Text_Display_mod(X, Y, W, H, l) {
|
||||
mCursorOn = 1;
|
||||
insert_mode_ = 1;
|
||||
key_bindings = 0;
|
||||
|
||||
// handle the default key bindings
|
||||
add_default_key_bindings(&key_bindings);
|
||||
|
||||
// handle everything else
|
||||
default_key_function(kf_default);
|
||||
}
|
||||
|
||||
Fl_Text_Editor_mod::Key_Binding* Fl_Text_Editor_mod::global_key_bindings = 0;
|
||||
|
||||
// These are the default key bindings every widget should start with
|
||||
static struct {
|
||||
int key;
|
||||
int state;
|
||||
Fl_Text_Editor_mod::Key_Func func;
|
||||
} default_key_bindings[] = {
|
||||
{ FL_Escape, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_ignore },
|
||||
{ FL_Enter, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_enter },
|
||||
{ FL_KP_Enter, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_enter },
|
||||
{ FL_BackSpace, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_backspace },
|
||||
{ FL_Insert, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_insert },
|
||||
{ FL_Delete, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_delete },
|
||||
{ FL_Home, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_End, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Left, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Up, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Right, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Down, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Page_Up, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Page_Down, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Home, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_End, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Left, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Up, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Right, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Down, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Page_Up, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Page_Down, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Home, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_End, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Left, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Up, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Right, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Down, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Page_Up, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Page_Down, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Home, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_End, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Left, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Up, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Right, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Down, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Page_Up, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Page_Down, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
//{ FL_Clear, 0, Fl_Text_Editor_mod::delete_to_eol },
|
||||
{ 'z', FL_CTRL, Fl_Text_Editor_mod::kf_undo },
|
||||
{ '/', FL_CTRL, Fl_Text_Editor_mod::kf_undo },
|
||||
{ 'x', FL_CTRL, Fl_Text_Editor_mod::kf_cut },
|
||||
{ FL_Delete, FL_SHIFT, Fl_Text_Editor_mod::kf_cut },
|
||||
{ 'c', FL_CTRL, Fl_Text_Editor_mod::kf_copy },
|
||||
{ FL_Insert, FL_CTRL, Fl_Text_Editor_mod::kf_copy },
|
||||
{ 'v', FL_CTRL, Fl_Text_Editor_mod::kf_paste },
|
||||
{ FL_Insert, FL_SHIFT, Fl_Text_Editor_mod::kf_paste },
|
||||
{ 'a', FL_CTRL, Fl_Text_Editor_mod::kf_select_all },
|
||||
|
||||
#ifdef __APPLE__
|
||||
// Define CMD+key accelerators...
|
||||
{ 'z', FL_COMMAND, Fl_Text_Editor_mod::kf_undo },
|
||||
{ 'x', FL_COMMAND, Fl_Text_Editor_mod::kf_cut },
|
||||
{ 'c', FL_COMMAND, Fl_Text_Editor_mod::kf_copy },
|
||||
{ 'v', FL_COMMAND, Fl_Text_Editor_mod::kf_paste },
|
||||
{ 'a', FL_COMMAND, Fl_Text_Editor_mod::kf_select_all },
|
||||
#endif // __APPLE__
|
||||
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
void Fl_Text_Editor_mod::add_default_key_bindings(Key_Binding** list) {
|
||||
for (int i = 0; default_key_bindings[i].key; i++) {
|
||||
add_key_binding(default_key_bindings[i].key,
|
||||
default_key_bindings[i].state,
|
||||
default_key_bindings[i].func,
|
||||
list);
|
||||
}
|
||||
}
|
||||
|
||||
Fl_Text_Editor_mod::Key_Func
|
||||
Fl_Text_Editor_mod::bound_key_function(int key, int state, Key_Binding* list) {
|
||||
Key_Binding* cur;
|
||||
for (cur = list; cur; cur = cur->next)
|
||||
if (cur->key == key)
|
||||
if (cur->state == FL_TEXT_EDITOR_ANY_STATE || cur->state == state)
|
||||
break;
|
||||
if (!cur) return 0;
|
||||
return cur->function;
|
||||
}
|
||||
|
||||
void
|
||||
Fl_Text_Editor_mod::remove_all_key_bindings(Key_Binding** list) {
|
||||
Key_Binding *cur, *next;
|
||||
for (cur = *list; cur; cur = next) {
|
||||
next = cur->next;
|
||||
delete cur;
|
||||
}
|
||||
*list = 0;
|
||||
}
|
||||
|
||||
void
|
||||
Fl_Text_Editor_mod::remove_key_binding(int key, int state, Key_Binding** list) {
|
||||
Key_Binding *cur, *last = 0;
|
||||
for (cur = *list; cur; last = cur, cur = cur->next)
|
||||
if (cur->key == key && cur->state == state) break;
|
||||
if (!cur) return;
|
||||
if (last) last->next = cur->next;
|
||||
else *list = cur->next;
|
||||
delete cur;
|
||||
}
|
||||
|
||||
void
|
||||
Fl_Text_Editor_mod::add_key_binding(int key, int state, Key_Func function,
|
||||
Key_Binding** list) {
|
||||
Key_Binding* kb = new Key_Binding;
|
||||
kb->key = key;
|
||||
kb->state = state;
|
||||
kb->function = function;
|
||||
kb->next = *list;
|
||||
*list = kb;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NORMAL_INPUT_MOVE 0
|
||||
|
||||
static void kill_selection(Fl_Text_Editor_mod* e) {
|
||||
if (e->buffer()->selected()) {
|
||||
e->insert_position(e->buffer()->primary_selection()->start());
|
||||
e->buffer()->remove_selection();
|
||||
}
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_default(int c, Fl_Text_Editor_mod* e) {
|
||||
if (!c || (!isprint(c) && c != '\t')) return 0;
|
||||
char s[2] = "\0";
|
||||
s[0] = (char)c;
|
||||
kill_selection(e);
|
||||
if (e->insert_mode()) e->insert(s);
|
||||
else e->overstrike(s);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_ignore(int, Fl_Text_Editor_mod*) {
|
||||
return 0; // don't handle
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_backspace(int, Fl_Text_Editor_mod* e) {
|
||||
if (!e->buffer()->selected() && e->move_left())
|
||||
e->buffer()->select(e->insert_position(), e->insert_position()+1);
|
||||
kill_selection(e);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_enter(int, Fl_Text_Editor_mod* e) {
|
||||
kill_selection(e);
|
||||
e->insert("\n");
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern void fl_text_drag_me(int pos, Fl_Text_Display_mod* d);
|
||||
|
||||
int Fl_Text_Editor_mod::kf_move(int c, Fl_Text_Editor_mod* e) {
|
||||
int i;
|
||||
int selected = e->buffer()->selected();
|
||||
if (!selected)
|
||||
e->dragPos = e->insert_position();
|
||||
e->buffer()->unselect();
|
||||
switch (c) {
|
||||
case FL_Home:
|
||||
e->insert_position(e->buffer()->line_start(e->insert_position()));
|
||||
break;
|
||||
case FL_End:
|
||||
e->insert_position(e->buffer()->line_end(e->insert_position()));
|
||||
break;
|
||||
case FL_Left:
|
||||
e->move_left();
|
||||
break;
|
||||
case FL_Right:
|
||||
e->move_right();
|
||||
break;
|
||||
case FL_Up:
|
||||
e->move_up();
|
||||
break;
|
||||
case FL_Down:
|
||||
e->move_down();
|
||||
break;
|
||||
case FL_Page_Up:
|
||||
for (i = 0; i < e->mNVisibleLines - 1; i++) e->move_up();
|
||||
break;
|
||||
case FL_Page_Down:
|
||||
for (i = 0; i < e->mNVisibleLines - 1; i++) e->move_down();
|
||||
break;
|
||||
}
|
||||
e->show_insert_position();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_shift_move(int c, Fl_Text_Editor_mod* e) {
|
||||
kf_move(c, e);
|
||||
fl_text_drag_me(e->insert_position(), e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_ctrl_move(int c, Fl_Text_Editor_mod* e) {
|
||||
if (!e->buffer()->selected())
|
||||
e->dragPos = e->insert_position();
|
||||
if (c != FL_Up && c != FL_Down) {
|
||||
e->buffer()->unselect();
|
||||
e->show_insert_position();
|
||||
}
|
||||
switch (c) {
|
||||
case FL_Home:
|
||||
e->insert_position(0);
|
||||
e->scroll(0, 0);
|
||||
break;
|
||||
case FL_End:
|
||||
e->insert_position(e->buffer()->length());
|
||||
e->scroll(e->count_lines(0, e->buffer()->length(), 1), 0);
|
||||
break;
|
||||
case FL_Left:
|
||||
e->previous_word();
|
||||
break;
|
||||
case FL_Right:
|
||||
e->next_word();
|
||||
break;
|
||||
case FL_Up:
|
||||
e->scroll(e->mTopLineNum-1, e->mHorizOffset);
|
||||
break;
|
||||
case FL_Down:
|
||||
e->scroll(e->mTopLineNum+1, e->mHorizOffset);
|
||||
break;
|
||||
case FL_Page_Up:
|
||||
e->insert_position(e->mLineStarts[0]);
|
||||
break;
|
||||
case FL_Page_Down:
|
||||
e->insert_position(e->mLineStarts[e->mNVisibleLines-2]);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_c_s_move(int c, Fl_Text_Editor_mod* e) {
|
||||
kf_ctrl_move(c, e);
|
||||
fl_text_drag_me(e->insert_position(), e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_home(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Home, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_end(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_End, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_left(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Left, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_up(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Up, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_right(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Right, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_down(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Down, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_page_up(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Page_Up, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_page_down(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Page_Down, e);
|
||||
}
|
||||
|
||||
|
||||
int Fl_Text_Editor_mod::kf_insert(int, Fl_Text_Editor_mod* e) {
|
||||
e->insert_mode(e->insert_mode() ? 0 : 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_delete(int, Fl_Text_Editor_mod* e) {
|
||||
if (!e->buffer()->selected())
|
||||
e->buffer()->select(e->insert_position(), e->insert_position()+1);
|
||||
kill_selection(e);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_copy(int, Fl_Text_Editor_mod* e) {
|
||||
if (!e->buffer()->selected()) return 1;
|
||||
const char *copy = e->buffer()->selection_text();
|
||||
if (*copy) Fl::copy(copy, strlen(copy), 1);
|
||||
free((void*)copy);
|
||||
e->show_insert_position();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_cut(int c, Fl_Text_Editor_mod* e) {
|
||||
kf_copy(c, e);
|
||||
kill_selection(e);
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_paste(int, Fl_Text_Editor_mod* e) {
|
||||
kill_selection(e);
|
||||
Fl::paste(*e, 1);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_select_all(int, Fl_Text_Editor_mod* e) {
|
||||
e->buffer()->select(0, e->buffer()->length());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_undo(int , Fl_Text_Editor_mod* e) {
|
||||
e->buffer()->unselect();
|
||||
int crsr;
|
||||
int ret = e->buffer()->undo(&crsr);
|
||||
e->insert_position(crsr);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::handle_key() {
|
||||
// Call FLTK's rules to try to turn this into a printing character.
|
||||
// This uses the right-hand ctrl key as a "compose prefix" and returns
|
||||
// the changes that should be made to the text, as a number of
|
||||
// bytes to delete and a string to insert:
|
||||
int del;
|
||||
if (Fl::compose(del)) {
|
||||
if (del) buffer()->select(insert_position()-del, insert_position());
|
||||
kill_selection(this);
|
||||
if (Fl::event_length()) {
|
||||
if (insert_mode()) insert(Fl::event_text());
|
||||
else overstrike(Fl::event_text());
|
||||
}
|
||||
show_insert_position();
|
||||
set_changed();
|
||||
if (when()&FL_WHEN_CHANGED) do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int key = Fl::event_key();
|
||||
// only care about these states
|
||||
int state = Fl::event_state() & (FL_SHIFT|FL_CTRL|FL_ALT|FL_META);
|
||||
Key_Func f;
|
||||
f = bound_key_function(key, state, global_key_bindings);
|
||||
if (!f) f = bound_key_function(key, state, key_bindings);
|
||||
if (f) return f(key, this);
|
||||
if (default_key_function_ && !state) {
|
||||
int c = Fl::event_text()[0];
|
||||
return default_key_function_(c, this);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Fl_Text_Editor_mod::maybe_do_callback() {
|
||||
// printf("Fl_Text_Editor_mod::maybe_do_callback()\n");
|
||||
// printf("changed()=%d, when()=%x\n", changed(), when());
|
||||
if (changed() || (when()&FL_WHEN_NOT_CHANGED)) do_callback();
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::handle(int event) {
|
||||
if (!buffer()) return 0;
|
||||
|
||||
switch (event) {
|
||||
case FL_FOCUS:
|
||||
show_cursor(mCursorOn); // redraws the cursor
|
||||
if (buffer()->selected()) redraw(); // Redraw selections...
|
||||
Fl::focus(this);
|
||||
return 1;
|
||||
|
||||
case FL_UNFOCUS:
|
||||
show_cursor(mCursorOn); // redraws the cursor
|
||||
if (buffer()->selected()) redraw(); // Redraw selections...
|
||||
case FL_HIDE:
|
||||
if (when() & FL_WHEN_RELEASE) maybe_do_callback();
|
||||
return 1;
|
||||
|
||||
case FL_KEYBOARD:
|
||||
if (active_r() && window() && this == Fl::belowmouse())
|
||||
window()->cursor(FL_CURSOR_NONE);
|
||||
return handle_key();
|
||||
|
||||
case FL_PASTE:
|
||||
if (!Fl::event_text()) {
|
||||
fl_beep();
|
||||
return 1;
|
||||
}
|
||||
buffer()->remove_selection();
|
||||
if (insert_mode()) insert(Fl::event_text());
|
||||
else overstrike(Fl::event_text());
|
||||
show_insert_position();
|
||||
set_changed();
|
||||
if (when()&FL_WHEN_CHANGED) do_callback();
|
||||
return 1;
|
||||
|
||||
case FL_ENTER:
|
||||
// MRS: WIN32 only? Need to test!
|
||||
// case FL_MOVE:
|
||||
show_cursor(mCursorOn);
|
||||
return 1;
|
||||
|
||||
case FL_PUSH:
|
||||
if (Fl::event_button() == 2) {
|
||||
// don't let the text_display see this event
|
||||
if (Fl_Group::handle(event)) return 1;
|
||||
dragType = -1;
|
||||
Fl::paste(*this, 0);
|
||||
Fl::focus(this);
|
||||
set_changed();
|
||||
if (when()&FL_WHEN_CHANGED) do_callback();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Fl_Text_Display_mod::handle(event);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Text_Editor.cxx 5671 2007-02-08 07:58:47Z matt $".
|
||||
//
|
||||
#if FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR < 3
|
||||
# include "Fl_Text_Editor_mod_1_1.cxx"
|
||||
#elif FLMSG_FLTK_API_MAJOR == 1 && FLMSG_FLTK_API_MINOR == 3
|
||||
# include "Fl_Text_Editor_mod_1_3.cxx"
|
||||
#endif
|
||||
|
|
|
|||
494
src/widgets/Fl_Text_Editor_mod_1_1.cxx
Normal file
494
src/widgets/Fl_Text_Editor_mod_1_1.cxx
Normal file
|
|
@ -0,0 +1,494 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Editor.cxx 5671 2007-02-08 07:58:47Z matt $"
|
||||
//
|
||||
// Copyright 2001-2006 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include "Fl_Text_Editor_mod.H"
|
||||
#include <FL/fl_ask.H>
|
||||
|
||||
|
||||
Fl_Text_Editor_mod::Fl_Text_Editor_mod(int X, int Y, int W, int H, const char* l)
|
||||
: Fl_Text_Display_mod(X, Y, W, H, l) {
|
||||
mCursorOn = 1;
|
||||
insert_mode_ = 1;
|
||||
key_bindings = 0;
|
||||
|
||||
// handle the default key bindings
|
||||
add_default_key_bindings(&key_bindings);
|
||||
|
||||
// handle everything else
|
||||
default_key_function(kf_default);
|
||||
}
|
||||
|
||||
Fl_Text_Editor_mod::Key_Binding* Fl_Text_Editor_mod::global_key_bindings = 0;
|
||||
|
||||
// These are the default key bindings every widget should start with
|
||||
static struct {
|
||||
int key;
|
||||
int state;
|
||||
Fl_Text_Editor_mod::Key_Func func;
|
||||
} default_key_bindings[] = {
|
||||
{ FL_Escape, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_ignore },
|
||||
{ FL_Enter, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_enter },
|
||||
{ FL_KP_Enter, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_enter },
|
||||
{ FL_BackSpace, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_backspace },
|
||||
{ FL_Insert, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_insert },
|
||||
{ FL_Delete, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_delete },
|
||||
{ FL_Home, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_End, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Left, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Up, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Right, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Down, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Page_Up, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Page_Down, 0, Fl_Text_Editor_mod::kf_move },
|
||||
{ FL_Home, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_End, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Left, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Up, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Right, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Down, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Page_Up, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Page_Down, FL_SHIFT, Fl_Text_Editor_mod::kf_shift_move },
|
||||
{ FL_Home, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_End, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Left, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Up, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Right, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Down, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Page_Up, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Page_Down, FL_CTRL, Fl_Text_Editor_mod::kf_ctrl_move },
|
||||
{ FL_Home, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_End, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Left, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Up, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Right, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Down, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Page_Up, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
{ FL_Page_Down, FL_CTRL|FL_SHIFT, Fl_Text_Editor_mod::kf_c_s_move },
|
||||
//{ FL_Clear, 0, Fl_Text_Editor_mod::delete_to_eol },
|
||||
{ 'z', FL_CTRL, Fl_Text_Editor_mod::kf_undo },
|
||||
{ '/', FL_CTRL, Fl_Text_Editor_mod::kf_undo },
|
||||
{ 'x', FL_CTRL, Fl_Text_Editor_mod::kf_cut },
|
||||
{ FL_Delete, FL_SHIFT, Fl_Text_Editor_mod::kf_cut },
|
||||
{ 'c', FL_CTRL, Fl_Text_Editor_mod::kf_copy },
|
||||
{ FL_Insert, FL_CTRL, Fl_Text_Editor_mod::kf_copy },
|
||||
{ 'v', FL_CTRL, Fl_Text_Editor_mod::kf_paste },
|
||||
{ FL_Insert, FL_SHIFT, Fl_Text_Editor_mod::kf_paste },
|
||||
{ 'a', FL_CTRL, Fl_Text_Editor_mod::kf_select_all },
|
||||
|
||||
#ifdef __APPLE__
|
||||
// Define CMD+key accelerators...
|
||||
{ 'z', FL_COMMAND, Fl_Text_Editor_mod::kf_undo },
|
||||
{ 'x', FL_COMMAND, Fl_Text_Editor_mod::kf_cut },
|
||||
{ 'c', FL_COMMAND, Fl_Text_Editor_mod::kf_copy },
|
||||
{ 'v', FL_COMMAND, Fl_Text_Editor_mod::kf_paste },
|
||||
{ 'a', FL_COMMAND, Fl_Text_Editor_mod::kf_select_all },
|
||||
#endif // __APPLE__
|
||||
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
void Fl_Text_Editor_mod::add_default_key_bindings(Key_Binding** list) {
|
||||
for (int i = 0; default_key_bindings[i].key; i++) {
|
||||
add_key_binding(default_key_bindings[i].key,
|
||||
default_key_bindings[i].state,
|
||||
default_key_bindings[i].func,
|
||||
list);
|
||||
}
|
||||
}
|
||||
|
||||
Fl_Text_Editor_mod::Key_Func
|
||||
Fl_Text_Editor_mod::bound_key_function(int key, int state, Key_Binding* list) {
|
||||
Key_Binding* cur;
|
||||
for (cur = list; cur; cur = cur->next)
|
||||
if (cur->key == key)
|
||||
if (cur->state == FL_TEXT_EDITOR_ANY_STATE || cur->state == state)
|
||||
break;
|
||||
if (!cur) return 0;
|
||||
return cur->function;
|
||||
}
|
||||
|
||||
void
|
||||
Fl_Text_Editor_mod::remove_all_key_bindings(Key_Binding** list) {
|
||||
Key_Binding *cur, *next;
|
||||
for (cur = *list; cur; cur = next) {
|
||||
next = cur->next;
|
||||
delete cur;
|
||||
}
|
||||
*list = 0;
|
||||
}
|
||||
|
||||
void
|
||||
Fl_Text_Editor_mod::remove_key_binding(int key, int state, Key_Binding** list) {
|
||||
Key_Binding *cur, *last = 0;
|
||||
for (cur = *list; cur; last = cur, cur = cur->next)
|
||||
if (cur->key == key && cur->state == state) break;
|
||||
if (!cur) return;
|
||||
if (last) last->next = cur->next;
|
||||
else *list = cur->next;
|
||||
delete cur;
|
||||
}
|
||||
|
||||
void
|
||||
Fl_Text_Editor_mod::add_key_binding(int key, int state, Key_Func function,
|
||||
Key_Binding** list) {
|
||||
Key_Binding* kb = new Key_Binding;
|
||||
kb->key = key;
|
||||
kb->state = state;
|
||||
kb->function = function;
|
||||
kb->next = *list;
|
||||
*list = kb;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NORMAL_INPUT_MOVE 0
|
||||
|
||||
static void kill_selection(Fl_Text_Editor_mod* e) {
|
||||
if (e->buffer()->selected()) {
|
||||
e->insert_position(e->buffer()->primary_selection()->start());
|
||||
e->buffer()->remove_selection();
|
||||
}
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_default(int c, Fl_Text_Editor_mod* e) {
|
||||
if (!c || (!isprint(c) && c != '\t')) return 0;
|
||||
char s[2] = "\0";
|
||||
s[0] = (char)c;
|
||||
kill_selection(e);
|
||||
if (e->insert_mode()) e->insert(s);
|
||||
else e->overstrike(s);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_ignore(int, Fl_Text_Editor_mod*) {
|
||||
return 0; // don't handle
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_backspace(int, Fl_Text_Editor_mod* e) {
|
||||
if (!e->buffer()->selected() && e->move_left())
|
||||
e->buffer()->select(e->insert_position(), e->insert_position()+1);
|
||||
kill_selection(e);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_enter(int, Fl_Text_Editor_mod* e) {
|
||||
kill_selection(e);
|
||||
e->insert("\n");
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern void fl_text_drag_me(int pos, Fl_Text_Display_mod* d);
|
||||
|
||||
int Fl_Text_Editor_mod::kf_move(int c, Fl_Text_Editor_mod* e) {
|
||||
int i;
|
||||
int selected = e->buffer()->selected();
|
||||
if (!selected)
|
||||
e->dragPos = e->insert_position();
|
||||
e->buffer()->unselect();
|
||||
switch (c) {
|
||||
case FL_Home:
|
||||
e->insert_position(e->buffer()->line_start(e->insert_position()));
|
||||
break;
|
||||
case FL_End:
|
||||
e->insert_position(e->buffer()->line_end(e->insert_position()));
|
||||
break;
|
||||
case FL_Left:
|
||||
e->move_left();
|
||||
break;
|
||||
case FL_Right:
|
||||
e->move_right();
|
||||
break;
|
||||
case FL_Up:
|
||||
e->move_up();
|
||||
break;
|
||||
case FL_Down:
|
||||
e->move_down();
|
||||
break;
|
||||
case FL_Page_Up:
|
||||
for (i = 0; i < e->mNVisibleLines - 1; i++) e->move_up();
|
||||
break;
|
||||
case FL_Page_Down:
|
||||
for (i = 0; i < e->mNVisibleLines - 1; i++) e->move_down();
|
||||
break;
|
||||
}
|
||||
e->show_insert_position();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_shift_move(int c, Fl_Text_Editor_mod* e) {
|
||||
kf_move(c, e);
|
||||
fl_text_drag_me(e->insert_position(), e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_ctrl_move(int c, Fl_Text_Editor_mod* e) {
|
||||
if (!e->buffer()->selected())
|
||||
e->dragPos = e->insert_position();
|
||||
if (c != FL_Up && c != FL_Down) {
|
||||
e->buffer()->unselect();
|
||||
e->show_insert_position();
|
||||
}
|
||||
switch (c) {
|
||||
case FL_Home:
|
||||
e->insert_position(0);
|
||||
e->scroll(0, 0);
|
||||
break;
|
||||
case FL_End:
|
||||
e->insert_position(e->buffer()->length());
|
||||
e->scroll(e->count_lines(0, e->buffer()->length(), 1), 0);
|
||||
break;
|
||||
case FL_Left:
|
||||
e->previous_word();
|
||||
break;
|
||||
case FL_Right:
|
||||
e->next_word();
|
||||
break;
|
||||
case FL_Up:
|
||||
e->scroll(e->mTopLineNum-1, e->mHorizOffset);
|
||||
break;
|
||||
case FL_Down:
|
||||
e->scroll(e->mTopLineNum+1, e->mHorizOffset);
|
||||
break;
|
||||
case FL_Page_Up:
|
||||
e->insert_position(e->mLineStarts[0]);
|
||||
break;
|
||||
case FL_Page_Down:
|
||||
e->insert_position(e->mLineStarts[e->mNVisibleLines-2]);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_c_s_move(int c, Fl_Text_Editor_mod* e) {
|
||||
kf_ctrl_move(c, e);
|
||||
fl_text_drag_me(e->insert_position(), e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_home(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Home, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_end(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_End, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_left(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Left, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_up(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Up, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_right(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Right, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_down(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Down, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_page_up(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Page_Up, e);
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_page_down(int, Fl_Text_Editor_mod* e) {
|
||||
return kf_move(FL_Page_Down, e);
|
||||
}
|
||||
|
||||
|
||||
int Fl_Text_Editor_mod::kf_insert(int, Fl_Text_Editor_mod* e) {
|
||||
e->insert_mode(e->insert_mode() ? 0 : 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_delete(int, Fl_Text_Editor_mod* e) {
|
||||
if (!e->buffer()->selected())
|
||||
e->buffer()->select(e->insert_position(), e->insert_position()+1);
|
||||
kill_selection(e);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_copy(int, Fl_Text_Editor_mod* e) {
|
||||
if (!e->buffer()->selected()) return 1;
|
||||
const char *copy = e->buffer()->selection_text();
|
||||
if (*copy) Fl::copy(copy, strlen(copy), 1);
|
||||
free((void*)copy);
|
||||
e->show_insert_position();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_cut(int c, Fl_Text_Editor_mod* e) {
|
||||
kf_copy(c, e);
|
||||
kill_selection(e);
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_paste(int, Fl_Text_Editor_mod* e) {
|
||||
kill_selection(e);
|
||||
Fl::paste(*e, 1);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_select_all(int, Fl_Text_Editor_mod* e) {
|
||||
e->buffer()->select(0, e->buffer()->length());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::kf_undo(int , Fl_Text_Editor_mod* e) {
|
||||
e->buffer()->unselect();
|
||||
int crsr;
|
||||
int ret = e->buffer()->undo(&crsr);
|
||||
e->insert_position(crsr);
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::handle_key() {
|
||||
// Call FLTK's rules to try to turn this into a printing character.
|
||||
// This uses the right-hand ctrl key as a "compose prefix" and returns
|
||||
// the changes that should be made to the text, as a number of
|
||||
// bytes to delete and a string to insert:
|
||||
int del;
|
||||
if (Fl::compose(del)) {
|
||||
if (del) buffer()->select(insert_position()-del, insert_position());
|
||||
kill_selection(this);
|
||||
if (Fl::event_length()) {
|
||||
if (insert_mode()) insert(Fl::event_text());
|
||||
else overstrike(Fl::event_text());
|
||||
}
|
||||
show_insert_position();
|
||||
set_changed();
|
||||
if (when()&FL_WHEN_CHANGED) do_callback();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int key = Fl::event_key(), state = Fl::event_state(), c = Fl::event_text()[0];
|
||||
state &= FL_SHIFT|FL_CTRL|FL_ALT|FL_META; // only care about these states
|
||||
Key_Func f;
|
||||
f = bound_key_function(key, state, global_key_bindings);
|
||||
if (!f) f = bound_key_function(key, state, key_bindings);
|
||||
if (f) return f(key, this);
|
||||
if (default_key_function_ && !state) return default_key_function_(c, this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Fl_Text_Editor_mod::maybe_do_callback() {
|
||||
// printf("Fl_Text_Editor_mod::maybe_do_callback()\n");
|
||||
// printf("changed()=%d, when()=%x\n", changed(), when());
|
||||
if (changed() || (when()&FL_WHEN_NOT_CHANGED)) do_callback();
|
||||
}
|
||||
|
||||
int Fl_Text_Editor_mod::handle(int event) {
|
||||
if (!buffer()) return 0;
|
||||
|
||||
switch (event) {
|
||||
case FL_FOCUS:
|
||||
show_cursor(mCursorOn); // redraws the cursor
|
||||
if (buffer()->selected()) redraw(); // Redraw selections...
|
||||
Fl::focus(this);
|
||||
return 1;
|
||||
|
||||
case FL_UNFOCUS:
|
||||
show_cursor(mCursorOn); // redraws the cursor
|
||||
if (buffer()->selected()) redraw(); // Redraw selections...
|
||||
case FL_HIDE:
|
||||
if (when() & FL_WHEN_RELEASE) maybe_do_callback();
|
||||
return 1;
|
||||
|
||||
case FL_KEYBOARD:
|
||||
if (active_r() && window() && this == Fl::belowmouse())
|
||||
window()->cursor(FL_CURSOR_NONE);
|
||||
return handle_key();
|
||||
|
||||
case FL_PASTE:
|
||||
if (!Fl::event_text()) {
|
||||
fl_beep();
|
||||
return 1;
|
||||
}
|
||||
buffer()->remove_selection();
|
||||
if (insert_mode()) insert(Fl::event_text());
|
||||
else overstrike(Fl::event_text());
|
||||
show_insert_position();
|
||||
set_changed();
|
||||
if (when()&FL_WHEN_CHANGED) do_callback();
|
||||
return 1;
|
||||
|
||||
case FL_ENTER:
|
||||
// MRS: WIN32 only? Need to test!
|
||||
// case FL_MOVE:
|
||||
show_cursor(mCursorOn);
|
||||
return 1;
|
||||
|
||||
case FL_PUSH:
|
||||
if (Fl::event_button() == 2) {
|
||||
// don't let the text_display see this event
|
||||
if (Fl_Group::handle(event)) return 1;
|
||||
dragType = -1;
|
||||
Fl::paste(*this, 0);
|
||||
Fl::focus(this);
|
||||
set_changed();
|
||||
if (when()&FL_WHEN_CHANGED) do_callback();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Fl_Text_Display_mod::handle(event);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Text_Editor.cxx 5671 2007-02-08 07:58:47Z matt $".
|
||||
//
|
||||
31
src/widgets/Fl_Text_Editor_mod_1_3.cxx
Normal file
31
src/widgets/Fl_Text_Editor_mod_1_3.cxx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// "$Id: Fl_Text_Editor_mod.cxx 8034 2010-12-15 12:21:55Z AlbrechtS $"
|
||||
//
|
||||
// Copyright 2001-2010 by Bill Spitzak and others.
|
||||
// Original code Copyright Mark Edel. Permission to distribute under
|
||||
// the LGPL for the FLTK library granted by Mark Edel.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Text_Editor_mod.cxx 8034 2010-12-15 12:21:55Z AlbrechtS $".
|
||||
//
|
||||
|
|
@ -1,22 +1,25 @@
|
|||
// =====================================================================
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// fileselect.cxx
|
||||
// fileselect.cxx -- file selector front end
|
||||
//
|
||||
// Author: Dave Freese, W1HKJ
|
||||
// Copyright: 2010
|
||||
// Copyright (C) 2008-2009
|
||||
// Stelios Bounanos, M0GLD
|
||||
//
|
||||
// This software is distributed in the hope that it will be useful,
|
||||
// This file is part of fldigi.
|
||||
//
|
||||
// Fldigi is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Fldigi is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is
|
||||
// copyright under the GNU General Public License.
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the program; if not, write to the Free Software
|
||||
// Foundation, Inc.
|
||||
// 59 Temple Place, Suite 330
|
||||
// Boston, MA 02111-1307 USA
|
||||
//
|
||||
// =====================================================================
|
||||
// along with fldigi. If not, see <http://www.gnu.org/licenses/>.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -88,7 +91,7 @@ void* FSEL::thread_func(void* arg)
|
|||
const char* FSEL::get_file(void)
|
||||
{
|
||||
// Calling directory() is apparently not enough on Linux
|
||||
#if !defined(__WIN32__) && !defined(__APPLE__)
|
||||
#if !defined(__WOE32__) && !defined(__APPLE__)
|
||||
const char* preset = chooser->preset_file();
|
||||
if (preset && *preset != '/' && chooser->directory()) {
|
||||
filename = chooser->directory();
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static char *strfree(char *val) {
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
#ifndef __WIN32__
|
||||
#ifndef __WOE32__
|
||||
// 'DYNAMICALLY' APPEND ONE STRING TO ANOTHER
|
||||
// Returns newly allocated string, or NULL
|
||||
// if s && val == NULL.
|
||||
|
|
|
|||
105
src/widgets/flstring.c
Normal file
105
src/widgets/flstring.c
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* "$Id: flstring.c 4288 2005-04-16 00:13:17Z mike $"
|
||||
*
|
||||
* BSD string functions for the Fast Light Tool Kit (FLTK).
|
||||
*
|
||||
* Copyright 1998-2005 by Bill Spitzak and others.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems on the following page:
|
||||
*
|
||||
* http://www.fltk.org/str.php
|
||||
*/
|
||||
|
||||
#include "flstring.h"
|
||||
|
||||
|
||||
/*
|
||||
* 'fl_strlcat()' - Safely concatenate two strings.
|
||||
*/
|
||||
|
||||
size_t /* O - Length of string */
|
||||
fl_strlcat(char *dst, /* O - Destination string */
|
||||
const char *src, /* I - Source string */
|
||||
size_t size) { /* I - Size of destination string buffer */
|
||||
size_t srclen; /* Length of source string */
|
||||
size_t dstlen; /* Length of destination string */
|
||||
|
||||
|
||||
/*
|
||||
* Figure out how much room is left...
|
||||
*/
|
||||
|
||||
dstlen = strlen(dst);
|
||||
size -= dstlen + 1;
|
||||
|
||||
if (!size) return (dstlen); /* No room, return immediately... */
|
||||
|
||||
/*
|
||||
* Figure out how much room is needed...
|
||||
*/
|
||||
|
||||
srclen = strlen(src);
|
||||
|
||||
/*
|
||||
* Copy the appropriate amount...
|
||||
*/
|
||||
|
||||
if (srclen > size) srclen = size;
|
||||
|
||||
memcpy(dst + dstlen, src, srclen);
|
||||
dst[dstlen + srclen] = '\0';
|
||||
|
||||
return (dstlen + srclen);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'fl_strlcpy()' - Safely copy two strings.
|
||||
*/
|
||||
|
||||
size_t /* O - Length of string */
|
||||
fl_strlcpy(char *dst, /* O - Destination string */
|
||||
const char *src, /* I - Source string */
|
||||
size_t size) { /* I - Size of destination string buffer */
|
||||
size_t srclen; /* Length of source string */
|
||||
|
||||
|
||||
/*
|
||||
* Figure out how much room is needed...
|
||||
*/
|
||||
|
||||
size --;
|
||||
|
||||
srclen = strlen(src);
|
||||
|
||||
/*
|
||||
* Copy the appropriate amount...
|
||||
*/
|
||||
|
||||
if (srclen > size) srclen = size;
|
||||
|
||||
memcpy(dst, src, srclen);
|
||||
dst[srclen] = '\0';
|
||||
|
||||
return (srclen);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* End of "$Id: flstring.c 4288 2005-04-16 00:13:17Z mike $".
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue