kopia lustrzana https://github.com/jamescoxon/dl-fldigi
Fltk-1.3.0
* Added conditional compilation for - Panel.cxx - Fl_Text_Buffer.cxx - Fl_Text_Display.cxx - Fl_Text_Editor.cxx - FTextView.cxx - FTextRXTX.cxx * Added code to support fast wrap - Rx text buffer serviced as a non-wrap buffer - new lines inserted into text stream when current line length exceeds the panel width - no attempt to recalculate word wrap if panel is resized - needed for slow cpu and OS X X implementation * Added margin adjuster * Removed horizontal scroll when word wrap enabled * Set vertical scroll to always visible - prevents unnecessary reformating of text when scroll bar goes from hidden to visible * Corrected faulty logic in handle_dnd for dragging file from file manager view to editor widget - SHIFT-dnd places object name into target widget - dnd places object contents into target widget - dnd multiple objects concatenates contents into target widget * Test for bottom of text visibility when programmatically adding characters to a text view or edit buffer (Rx/Tx) * Implemented common FSEL methods for Fltk 1.3.0 - 1.3.0 used common calls for all supported OSpull/1/head
rodzic
faff489972
commit
23b9a177d2
|
@ -18,6 +18,7 @@ if test "x$target_win32" = "xyes"; then
|
||||||
AC_MSG_WARN([The windres utility could not be found])
|
AC_MSG_WARN([The windres utility could not be found])
|
||||||
fi
|
fi
|
||||||
AC_DEFINE([__WOE32__], 1, [Define to 1 if we are building on cygwin or mingw])
|
AC_DEFINE([__WOE32__], 1, [Define to 1 if we are building on cygwin or mingw])
|
||||||
|
AC_DEFINE([__MINGW32__], 1, [Define to 1 if we are building on cygwin or mingw])
|
||||||
AC_DEFINE([_WINDOWS], 1, [Define to 1 if we are building on cygwin or mingw])
|
AC_DEFINE([_WINDOWS], 1, [Define to 1 if we are building on cygwin or mingw])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -546,6 +546,8 @@ EXTRA_fldigi_SOURCES += \
|
||||||
fileselector/Fl_Native_File_Chooser_MAC.cxx \
|
fileselector/Fl_Native_File_Chooser_MAC.cxx \
|
||||||
fileselector/Fl_Native_File_Chooser_WIN32.cxx \
|
fileselector/Fl_Native_File_Chooser_WIN32.cxx \
|
||||||
fileselector/flnfc_common.cxx \
|
fileselector/flnfc_common.cxx \
|
||||||
|
fileselector/fileselect_1_1.cxx \
|
||||||
|
fileselector/fileselect_1_3.cxx \
|
||||||
feld/Feld7x7-14.cxx \
|
feld/Feld7x7-14.cxx \
|
||||||
feld/Feld7x7n-14.cxx \
|
feld/Feld7x7n-14.cxx \
|
||||||
feld/FeldDx-14.cxx \
|
feld/FeldDx-14.cxx \
|
||||||
|
|
|
@ -41,7 +41,23 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <dirent.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 FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3
|
||||||
|
# undef dirent
|
||||||
|
# include <dirent.h>
|
||||||
|
# else
|
||||||
|
# include <dirent.h>
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <dirent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __WOE32__
|
#ifndef __WOE32__
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
@ -3430,7 +3446,11 @@ int rightof(Fl_Widget* w)
|
||||||
|
|
||||||
int leftof(Fl_Widget* w)
|
int leftof(Fl_Widget* w)
|
||||||
{
|
{
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
unsigned int a = w->align();
|
||||||
|
#else
|
||||||
int a = w->align();
|
int a = w->align();
|
||||||
|
#endif
|
||||||
if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
|
if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
|
||||||
return w->x();
|
return w->x();
|
||||||
|
|
||||||
|
@ -3455,7 +3475,11 @@ int leftof(Fl_Widget* w)
|
||||||
|
|
||||||
int above(Fl_Widget* w)
|
int above(Fl_Widget* w)
|
||||||
{
|
{
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
unsigned int a = w->align();
|
||||||
|
#else
|
||||||
int a = w->align();
|
int a = w->align();
|
||||||
|
#endif
|
||||||
if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
|
if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
|
||||||
return w->y();
|
return w->y();
|
||||||
|
|
||||||
|
@ -3464,7 +3488,11 @@ int above(Fl_Widget* w)
|
||||||
|
|
||||||
int below(Fl_Widget* w)
|
int below(Fl_Widget* w)
|
||||||
{
|
{
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
unsigned int a = w->align();
|
||||||
|
#else
|
||||||
int a = w->align();
|
int a = w->align();
|
||||||
|
#endif
|
||||||
if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
|
if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
|
||||||
return w->y() + w->h();
|
return w->y() + w->h();
|
||||||
|
|
||||||
|
@ -5782,6 +5810,7 @@ int Qidle_time = 0;
|
||||||
|
|
||||||
static int que_timeout = 0;
|
static int que_timeout = 0;
|
||||||
bool que_ok = true;
|
bool que_ok = true;
|
||||||
|
bool que_waiting = true;
|
||||||
|
|
||||||
void post_queue_execute(void*)
|
void post_queue_execute(void*)
|
||||||
{
|
{
|
||||||
|
@ -5798,6 +5827,7 @@ void post_queue_execute(void*)
|
||||||
|
|
||||||
void queue_execute_after_rx(void*)
|
void queue_execute_after_rx(void*)
|
||||||
{
|
{
|
||||||
|
que_waiting = false;
|
||||||
if (!que_timeout) {
|
if (!que_timeout) {
|
||||||
LOG_ERROR("%s", "timed out");
|
LOG_ERROR("%s", "timed out");
|
||||||
return;
|
return;
|
||||||
|
@ -5813,6 +5843,12 @@ void queue_execute_after_rx(void*)
|
||||||
queue_execute();
|
queue_execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void do_que_execute(void *)
|
||||||
|
{
|
||||||
|
que_waiting = false;
|
||||||
|
queue_execute();
|
||||||
|
}
|
||||||
|
|
||||||
char szTestChar[] = "E|I|S|T|M|O|A|V";
|
char szTestChar[] = "E|I|S|T|M|O|A|V";
|
||||||
int get_tx_char(void)
|
int get_tx_char(void)
|
||||||
{
|
{
|
||||||
|
@ -5911,10 +5947,12 @@ int get_tx_char(void)
|
||||||
if (queue_must_rx()) {
|
if (queue_must_rx()) {
|
||||||
c = 3;
|
c = 3;
|
||||||
que_timeout = 400; // 20 seconds
|
que_timeout = 400; // 20 seconds
|
||||||
Fl::add_timeout(0.0, queue_execute_after_rx);
|
REQ(queue_execute_after_rx, (void *)0);
|
||||||
|
while(que_waiting) MilliSleep(1);
|
||||||
} else {
|
} else {
|
||||||
c = -1;
|
c = -1;
|
||||||
queue_execute();
|
REQ(do_que_execute, (void*)0);
|
||||||
|
while(que_waiting) MilliSleep(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '^':
|
case '^':
|
||||||
|
|
|
@ -19,10 +19,13 @@
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#if (FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3) || (FLARQ_FLTK_API_MAJOR == 1 && FLARQ_FLTK_API_MINOR < 3)
|
||||||
|
|
||||||
// Use Windows' chooser
|
// Use Windows' chooser
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
#include "Fl_Native_File_Chooser_WIN32.cxx"
|
#include "Fl_Native_File_Chooser_WIN32.cxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -36,3 +39,4 @@
|
||||||
#include "Fl_Native_File_Chooser_FLTK.cxx"
|
#include "Fl_Native_File_Chooser_FLTK.cxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -23,167 +23,12 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <string>
|
#if (FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3) || (FLARQ_FLTK_API_MAJOR == 1 && FLARQ_FLTK_API_MINOR < 3)
|
||||||
#include <cstdlib>
|
|
||||||
#include <libgen.h>
|
|
||||||
|
|
||||||
#include "fileselect.h"
|
# include "fileselect_1_1.cxx"
|
||||||
#include "icons.h"
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
#include <FL/fl_ask.H>
|
|
||||||
#include <FL/Fl_Native_File_Chooser.H>
|
|
||||||
|
|
||||||
#if FSEL_THREAD
|
|
||||||
# include <FL/Fl.H>
|
|
||||||
# include <semaphore.h>
|
|
||||||
# include "threads.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
FSEL* FSEL::inst = 0;
|
|
||||||
static std::string filename;
|
|
||||||
#if FSEL_THREAD
|
|
||||||
static pthread_t fsel_thread;
|
|
||||||
sem_t fsel_sem;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void FSEL::create(void)
|
|
||||||
{
|
|
||||||
if (inst)
|
|
||||||
return;
|
|
||||||
#if FSEL_THREAD
|
|
||||||
if (sem_init(&fsel_sem, 0, 0) == -1) {
|
|
||||||
LOG_PERROR("sem_init");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
inst = new FSEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FSEL::destroy(void)
|
|
||||||
{
|
|
||||||
#if FSEL_THREAD
|
|
||||||
sem_destroy(&fsel_sem);
|
|
||||||
#endif
|
|
||||||
delete inst;
|
|
||||||
inst = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FSEL::FSEL()
|
|
||||||
: chooser(new Fl_Native_File_Chooser) { }
|
|
||||||
FSEL::~FSEL() { delete chooser; }
|
|
||||||
|
|
||||||
|
|
||||||
#if FSEL_THREAD
|
|
||||||
void* FSEL::thread_func(void* arg)
|
|
||||||
{
|
|
||||||
FSEL* fsel = reinterpret_cast<FSEL*>(arg);
|
|
||||||
fsel->result = fsel->chooser->show();
|
|
||||||
sem_post(&fsel_sem);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char* FSEL::get_file(void)
|
|
||||||
{
|
|
||||||
// Calling directory() is apparently not enough on Linux
|
|
||||||
#if !defined(__WOE32__) && !defined(__APPLE__)
|
|
||||||
const char* preset = chooser->preset_file();
|
|
||||||
if (preset && *preset != '/' && chooser->directory()) {
|
|
||||||
filename = chooser->directory();
|
|
||||||
filename.append("/").append(preset);
|
|
||||||
chooser->preset_file(filename.c_str());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if FSEL_THREAD
|
|
||||||
if (pthread_create(&fsel_thread, NULL, thread_func, this) != 0) {
|
|
||||||
fl_alert2("could not create file selector thread");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
for (;;) {
|
|
||||||
if (sem_trywait(&fsel_sem) == 0)
|
|
||||||
break;
|
|
||||||
Fl::wait(0.1);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
result = chooser->show();
|
|
||||||
|
# include "fileselect_1_3.cxx"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (result) {
|
|
||||||
case -1:
|
|
||||||
fl_alert2("%s", chooser->errmsg());
|
|
||||||
// fall through
|
|
||||||
case 1:
|
|
||||||
return NULL;
|
|
||||||
default:
|
|
||||||
filename = chooser->filename();
|
|
||||||
string::size_type i = filename.rfind('/');
|
|
||||||
if (i != string::npos)
|
|
||||||
chooser->directory(filename.substr(0, i).c_str());
|
|
||||||
return filename.c_str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* FSEL::select(const char* title, const char* filter, const char* def, int* fsel)
|
|
||||||
{
|
|
||||||
inst->chooser->title(title);
|
|
||||||
inst->chooser->filter(filter);
|
|
||||||
if (def) {
|
|
||||||
char *s = strdup(def), *dir = dirname(s);
|
|
||||||
if (strcmp(".", dir))
|
|
||||||
inst->chooser->directory(dir);
|
|
||||||
free(s);
|
|
||||||
s = strdup(def);
|
|
||||||
inst->chooser->preset_file(basename(s));
|
|
||||||
free(s);
|
|
||||||
}
|
|
||||||
inst->chooser->options(Fl_Native_File_Chooser::PREVIEW);
|
|
||||||
inst->chooser->type(Fl_Native_File_Chooser::BROWSE_FILE);
|
|
||||||
|
|
||||||
const char* fn = inst->get_file();
|
|
||||||
if (fsel)
|
|
||||||
*fsel = inst->chooser->filter_value();
|
|
||||||
return fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* FSEL::saveas(const char* title, const char* filter, const char* def, int* fsel)
|
|
||||||
{
|
|
||||||
inst->chooser->title(title);
|
|
||||||
inst->chooser->filter(filter);
|
|
||||||
if (def) {
|
|
||||||
char *s = strdup(def), *dir = dirname(s);
|
|
||||||
if (strcmp(".", dir))
|
|
||||||
inst->chooser->directory(dir);
|
|
||||||
free(s);
|
|
||||||
s = strdup(def);
|
|
||||||
inst->chooser->preset_file(basename(s));
|
|
||||||
free(s);
|
|
||||||
}
|
|
||||||
inst->chooser->options(Fl_Native_File_Chooser::SAVEAS_CONFIRM |
|
|
||||||
Fl_Native_File_Chooser::NEW_FOLDER |
|
|
||||||
Fl_Native_File_Chooser::PREVIEW);
|
|
||||||
inst->chooser->type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE);
|
|
||||||
|
|
||||||
const char* fn = inst->get_file();
|
|
||||||
if (fsel)
|
|
||||||
*fsel = inst->chooser->filter_value();
|
|
||||||
return fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* FSEL::dir_select(const char* title, const char* filter, const char* def)
|
|
||||||
{
|
|
||||||
inst->chooser->title(title);
|
|
||||||
inst->chooser->filter(filter);
|
|
||||||
if (def)
|
|
||||||
inst->chooser->directory(def);
|
|
||||||
inst->chooser->options(Fl_Native_File_Chooser::NEW_FOLDER |
|
|
||||||
Fl_Native_File_Chooser::PREVIEW);
|
|
||||||
inst->chooser->type(Fl_Native_File_Chooser::BROWSE_DIRECTORY);
|
|
||||||
|
|
||||||
return inst->get_file();
|
|
||||||
}
|
|
||||||
|
|
|
@ -47,6 +47,23 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// 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 FLARQ_FLTK_API_MAJOR == 1 && FLARQ_FLTK_API_MINOR < 3
|
||||||
|
# undef dirent
|
||||||
|
# include <dirent.h>
|
||||||
|
# else
|
||||||
|
# include <dirent.h>
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <dirent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "flarq.h"
|
#include "flarq.h"
|
||||||
#include "arq.h"
|
#include "arq.h"
|
||||||
#include "arqdialogs.h"
|
#include "arqdialogs.h"
|
||||||
|
|
|
@ -44,16 +44,25 @@
|
||||||
#include <FL/Fl_Help_Dialog.H>
|
#include <FL/Fl_Help_Dialog.H>
|
||||||
#include <FL/Fl_Menu_Item.H>
|
#include <FL/Fl_Menu_Item.H>
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
// this tests depends on a modified FL/filename.H in the Fltk-1.3.0
|
||||||
# include "compat.h"
|
// change
|
||||||
#endif
|
//# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
||||||
|
// to
|
||||||
|
//# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) && !defined(__WOE32__)
|
||||||
|
|
||||||
|
#include <FL/filename.H>
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
# define dirent fl_dirent_no_thanks
|
# include "compat.h"
|
||||||
#endif
|
# if FLARQ_FLTK_API_MAJOR == 1 && FLARQ_FLTK_API_MINOR < 3
|
||||||
#include <FL/filename.H>
|
# define dirent fl_dirent_no_thanks
|
||||||
#ifdef __MINGW32__
|
# undef dirent
|
||||||
# undef dirent
|
# include <dirent.h>
|
||||||
|
# else
|
||||||
|
# include <dirent.h>
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "fileselect.h"
|
#include "fileselect.h"
|
||||||
|
|
Plik diff jest za duży
Load Diff
|
@ -1,9 +1,9 @@
|
||||||
//
|
//
|
||||||
// "$Id: Fl_Text_Display.H 6902 2009-09-27 11:06:56Z matt $"
|
// "$Id: Fl_Text_Display_mod.H 8306 2011-01-24 17:04:22Z matt $"
|
||||||
//
|
//
|
||||||
// Header file for Fl_Text_Display class.
|
// Header file for Fl_Text_Display_mod class.
|
||||||
//
|
//
|
||||||
// Copyright 2001-2009 by Bill Spitzak and others.
|
// Copyright 2001-2010 by Bill Spitzak and others.
|
||||||
// Original code Copyright Mark Edel. Permission to distribute under
|
// Original code Copyright Mark Edel. Permission to distribute under
|
||||||
// the LGPL for the FLTK library granted by Mark Edel.
|
// the LGPL for the FLTK library granted by Mark Edel.
|
||||||
//
|
//
|
||||||
|
@ -28,10 +28,12 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
/* \file
|
/* \file
|
||||||
Fl_Text_Display widget . */
|
Fl_Text_Display_mod widget . */
|
||||||
|
|
||||||
#ifndef FL_TEXT_DISPLAY_H
|
#ifndef Fl_Text_Display_mod_H
|
||||||
#define FL_TEXT_DISPLAY_H
|
#define Fl_Text_Display_mod_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <FL/fl_draw.H>
|
#include <FL/fl_draw.H>
|
||||||
#include <FL/Fl_Group.H>
|
#include <FL/Fl_Group.H>
|
||||||
|
@ -40,311 +42,451 @@
|
||||||
#include "Fl_Text_Buffer_mod.H"
|
#include "Fl_Text_Buffer_mod.H"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is the FLTK text display widget. It allows the user to
|
\brief Rich text display widget.
|
||||||
view multiple lines of text and supports highlighting and
|
|
||||||
scrolling. The buffer that is displayed in the widget is managed
|
This is the FLTK text display widget. It allows the user to view multiple lines
|
||||||
by the Fl_Text_Buffer
|
of text and supports highlighting and scrolling. The buffer that is displayed
|
||||||
class.
|
in the widget is managed by the Fl_Text_Buffer_mod class. A single Text Buffer
|
||||||
*/
|
can be displayed by multiple Text Displays.
|
||||||
|
*/
|
||||||
class FL_EXPORT Fl_Text_Display_mod: public Fl_Group {
|
class FL_EXPORT Fl_Text_Display_mod: public Fl_Group {
|
||||||
public:
|
|
||||||
/** text display cursor shapes enumeration */
|
|
||||||
enum {
|
|
||||||
NORMAL_CURSOR, CARET_CURSOR, DIM_CURSOR,
|
|
||||||
BLOCK_CURSOR, HEAVY_CURSOR
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
public:
|
||||||
CURSOR_POS, CHARACTER_POS
|
|
||||||
};
|
/**
|
||||||
|
text display cursor shapes enumeration
|
||||||
/** drag types- they match Fl::event_clicks() so that single clicking to
|
*/
|
||||||
start a collection selects by character, double clicking selects by
|
enum {
|
||||||
word and triple clicking selects by line.
|
NORMAL_CURSOR, /**< I-beam */
|
||||||
*/
|
CARET_CURSOR, /**< caret under the text */
|
||||||
enum {
|
DIM_CURSOR, /**< dim I-beam */
|
||||||
DRAG_CHAR = 0, DRAG_WORD = 1, DRAG_LINE = 2
|
BLOCK_CURSOR, /**< unfille box under the current character */
|
||||||
};
|
HEAVY_CURSOR /**< thick I-beam */
|
||||||
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
|
|
||||||
};
|
|
||||||
/** This structure associates the color,font,size of a string to draw
|
|
||||||
with an attribute mask matching attr */
|
|
||||||
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);
|
|
||||||
/**
|
/**
|
||||||
Sets or gets the current text buffer associated with the text widget.
|
the character position is the left edge of a character, whereas
|
||||||
Multiple text widgets can be associated with the same text buffer.
|
the cursor is thought to be between the centers of two consecutive
|
||||||
*/
|
characters.
|
||||||
void buffer(Fl_Text_Buffer_mod& buf) { buffer(&buf); }
|
*/
|
||||||
/**
|
enum {
|
||||||
Gets the current text buffer associated with the text widget.
|
CURSOR_POS,
|
||||||
Multiple text widgets can be associated with the same text buffer.
|
CHARACTER_POS
|
||||||
*/
|
};
|
||||||
Fl_Text_Buffer_mod* buffer() const { return mBuffer; }
|
|
||||||
void redisplay_range(int start, int end);
|
/**
|
||||||
void scroll(int topLineNum, int horizOffset);
|
drag types - they match Fl::event_clicks() so that single clicking to
|
||||||
void insert(const char* text);
|
start a collection selects by character, double clicking selects by
|
||||||
void overstrike(const char* text);
|
word and triple clicking selects by line.
|
||||||
void insert_position(int newPos);
|
*/
|
||||||
/** Gets the position of the text insertion cursor for text display */
|
enum {
|
||||||
int insert_position() const { return mCursorPos; }
|
DRAG_NONE = -2,
|
||||||
int in_selection(int x, int y) const;
|
DRAG_START_DND = -1,
|
||||||
void show_insert_position();
|
DRAG_CHAR = 0,
|
||||||
int move_right();
|
DRAG_WORD = 1,
|
||||||
int move_left();
|
DRAG_LINE = 2
|
||||||
int move_up();
|
};
|
||||||
int move_down();
|
|
||||||
int count_lines(int start, int end, bool start_pos_is_line_start) const;
|
/**
|
||||||
int line_start(int pos) const;
|
wrap types - used in wrap_mode()
|
||||||
int line_end(int pos, bool start_pos_is_line_start) const;
|
*/
|
||||||
int skip_lines(int startPos, int nLines, bool startPosIsLineStart);
|
enum {
|
||||||
int rewind_lines(int startPos, int nLines);
|
WRAP_NONE, /**< don't wrap text at all */
|
||||||
void next_word(void);
|
WRAP_AT_COLUMN, /**< wrap text at the given text column */
|
||||||
void previous_word(void);
|
WRAP_AT_PIXEL, /**< wrap text at a pixel position */
|
||||||
void show_cursor(int b = 1);
|
WRAP_AT_BOUNDS /**< wrap text so that it fits into the widget width */
|
||||||
/** Hides the text cursor */
|
};
|
||||||
void hide_cursor() { show_cursor(0); }
|
|
||||||
void cursor_style(int style);
|
friend void fl_text_drag_me(int pos, Fl_Text_Display_mod* d);
|
||||||
/** Sets or gets the text cursor color. */
|
|
||||||
Fl_Color cursor_color() const {return mCursor_color;}
|
typedef void (*Unfinished_Style_Cb)(int, void *);
|
||||||
/** Sets or gets the text cursor color. */
|
|
||||||
void cursor_color(Fl_Color n) {mCursor_color = n;}
|
/**
|
||||||
/** Sets or gets the width/height of the scrollbars. */
|
This structure associates the color, font, andsize of a string to draw
|
||||||
int scrollbar_width() const { return scrollbar_width_; }
|
with an attribute mask matching attr
|
||||||
/** Sets or gets the width/height of the scrollbars. */
|
*/
|
||||||
void scrollbar_width(int W) { scrollbar_width_ = W; }
|
struct Style_Table_Entry {
|
||||||
/** Gets the scrollbar alignment type */
|
Fl_Color color;
|
||||||
Fl_Align scrollbar_align() const { return scrollbar_align_; }
|
Fl_Font font;
|
||||||
/** Sets the scrollbar alignment type */
|
Fl_Fontsize size;
|
||||||
void scrollbar_align(Fl_Align a) { scrollbar_align_ = a; }
|
unsigned attr;
|
||||||
/** Moves the insert position to the beginning of the current word. */
|
};
|
||||||
int word_start(int pos) const { return buffer()->word_start(pos); }
|
|
||||||
/** Moves the insert position to the end of the current word. */
|
Fl_Text_Display_mod(int X, int Y, int W, int H, const char *l = 0);
|
||||||
int word_end(int pos) const { return buffer()->word_end(pos); }
|
~Fl_Text_Display_mod();
|
||||||
|
|
||||||
|
virtual int handle(int e);
|
||||||
|
|
||||||
|
void buffer(Fl_Text_Buffer_mod* buf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the current text buffer associated with the text widget.
|
||||||
|
Multiple text widgets can be associated with the same text buffer.
|
||||||
|
\param buf new text buffer
|
||||||
|
*/
|
||||||
|
void buffer(Fl_Text_Buffer_mod& buf) { buffer(&buf); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the current text buffer associated with the text widget.
|
||||||
|
Multiple text widgets can be associated with the same text buffer.
|
||||||
|
\return current text buffer
|
||||||
|
*/
|
||||||
|
Fl_Text_Buffer_mod* buffer() const { 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the position of the text insertion cursor for text display.
|
||||||
|
\return insert position index into text buffer
|
||||||
|
*/
|
||||||
|
int insert_position() const { return mCursorPos; }
|
||||||
|
int position_to_xy(int pos, int* x, int* y) const;
|
||||||
|
|
||||||
|
int in_selection(int x, int y) const;
|
||||||
void highlight_data(Fl_Text_Buffer_mod *styleBuffer,
|
void show_insert_position();
|
||||||
const Style_Table_Entry *styleTable,
|
|
||||||
int nStyles, char unfinishedStyle,
|
int move_right();
|
||||||
Unfinished_Style_Cb unfinishedHighlightCB,
|
int move_left();
|
||||||
void *cbArg);
|
int move_up();
|
||||||
|
int move_down();
|
||||||
|
int count_lines(int start, int end, bool start_pos_is_line_start) const;
|
||||||
|
int line_start(int pos) const;
|
||||||
|
int line_end(int startPos, bool startPosIsLineStart) const;
|
||||||
|
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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Hides the text cursor.
|
||||||
|
*/
|
||||||
|
void hide_cursor() { show_cursor(0); }
|
||||||
|
|
||||||
|
void cursor_style(int style);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the text cursor color.
|
||||||
|
\return cursor color
|
||||||
|
*/
|
||||||
|
Fl_Color cursor_color() const {return mCursor_color;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the text cursor color.
|
||||||
|
\param n new cursor color
|
||||||
|
*/
|
||||||
|
void cursor_color(Fl_Color n) {mCursor_color = n;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the width/height of the scrollbars.
|
||||||
|
/return width of scrollbars
|
||||||
|
*/
|
||||||
|
int scrollbar_width() const { return scrollbar_width_; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the width/height of the scrollbars.
|
||||||
|
\param W width of scrollbars
|
||||||
|
*/
|
||||||
|
void scrollbar_width(int W) { scrollbar_width_ = W; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the scrollbar alignment type.
|
||||||
|
\return scrollbar alignment
|
||||||
|
*/
|
||||||
|
Fl_Align scrollbar_align() const { return scrollbar_align_; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the scrollbar alignment type.
|
||||||
|
\param a new scrollbar alignment
|
||||||
|
*/
|
||||||
|
void scrollbar_align(Fl_Align a) { scrollbar_align_ = a; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Moves the insert position to the beginning of the current word.
|
||||||
|
\param pos start calculation at this index
|
||||||
|
\return beginning of the words
|
||||||
|
*/
|
||||||
|
int word_start(int pos) const { return buffer()->word_start(pos); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Moves the insert position to the end of the current word.
|
||||||
|
\param pos start calculation at this index
|
||||||
|
\return index of first character after the end of the word
|
||||||
|
*/
|
||||||
|
int word_end(int pos) const { 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) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
\todo FIXME : get set methods pointing on shortcut_
|
||||||
|
have no effects as shortcut_ is unused in this class and derived!
|
||||||
|
\return the current shortcut key
|
||||||
|
*/
|
||||||
|
int shortcut() const {return shortcut_;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
\todo FIXME : get set methods pointing on shortcut_
|
||||||
|
have no effects as shortcut_ is unused in this class and derived!
|
||||||
|
\param s the new shortcut key
|
||||||
|
*/
|
||||||
|
void shortcut(int s) {shortcut_ = s;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the default font used when drawing text in the widget.
|
||||||
|
\return current text font face unless overridden by a style
|
||||||
|
*/
|
||||||
|
Fl_Font textfont() const {return textfont_;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the default font used when drawing text in the widget.
|
||||||
|
\param s default text font face
|
||||||
|
*/
|
||||||
|
void textfont(Fl_Font s) {textfont_ = s; mColumnScale = 0;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the default size of text in the widget.
|
||||||
|
\return current text height unless overridden by a style
|
||||||
|
*/
|
||||||
|
Fl_Fontsize textsize() const {return textsize_;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the default size of text in the widget.
|
||||||
|
\param s new text size
|
||||||
|
*/
|
||||||
|
void textsize(Fl_Fontsize s) {textsize_ = s; mColumnScale = 0;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the default color of text in the widget.
|
||||||
|
\return text color unless overridden by a style
|
||||||
|
*/
|
||||||
|
Fl_Color textcolor() const {return textcolor_;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the default color of text in the widget.
|
||||||
|
\param n new text color
|
||||||
|
*/
|
||||||
|
void textcolor(Fl_Color n) {textcolor_ = n;}
|
||||||
|
|
||||||
|
int wrapped_column(int row, int column) const;
|
||||||
|
int wrapped_row(int row) const;
|
||||||
|
void wrap_mode(int wrap, int wrap_margin);
|
||||||
|
|
||||||
|
virtual void resize(int X, int Y, int W, int H);
|
||||||
|
|
||||||
int position_style(int lineStartPos, int lineLen, int lineIndex,
|
/**
|
||||||
int dispIndex) const;
|
Convert an x pixel position into a column number.
|
||||||
/** \todo FIXME : get set methods pointing on shortcut_
|
\param x number of pixels from the left margin
|
||||||
have no effects as shortcut_ is unused in this class and derived! */
|
\return an approximate column number based on the main font
|
||||||
int shortcut() const {return shortcut_;}
|
*/
|
||||||
/** \todo FIXME : get set methods pointing on shortcut_
|
double x_to_col(double x) const;
|
||||||
have no effects as shortcut_ is unused in this class and derived! */
|
|
||||||
void shortcut(int s) {shortcut_ = s;}
|
/**
|
||||||
|
Convert a column number into an x pixel position.
|
||||||
|
\param col an approximate column number based on the main font
|
||||||
|
\return number of pixels from the left margin to the left of an
|
||||||
|
average sized character
|
||||||
|
*/
|
||||||
|
double col_to_x(double col) const;
|
||||||
|
|
||||||
|
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) const;
|
||||||
|
|
||||||
|
void draw_vline(int visLineNum, int leftClip, int rightClip,
|
||||||
|
int leftCharIndex, int rightCharIndex);
|
||||||
|
|
||||||
|
int find_x(const char *s, int len, int style, int x) const;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
DRAW_LINE,
|
||||||
|
FIND_INDEX,
|
||||||
|
FIND_INDEX_FROM_ZERO,
|
||||||
|
GET_WIDTH
|
||||||
|
};
|
||||||
|
|
||||||
|
int handle_vline(int mode,
|
||||||
|
int lineStart, int lineLen, int leftChar, int rightChar,
|
||||||
|
int topClip, int bottomClip,
|
||||||
|
int leftClip, int rightClip) const;
|
||||||
|
|
||||||
|
void draw_line_numbers(bool clearAll);
|
||||||
|
|
||||||
|
void clear_rect(int style, int x, int y, int width, int height) const;
|
||||||
|
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 ) const;
|
||||||
|
double string_width(const char* string, int length, int style) const;
|
||||||
|
|
||||||
|
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) const;
|
||||||
|
int longest_vline() const;
|
||||||
|
int empty_vlines() const;
|
||||||
|
int vline_length(int visLineNum) const;
|
||||||
|
int xy_to_position(int x, int y, int PosType = CHARACTER_POS) const;
|
||||||
|
|
||||||
|
void xy_to_rowcol(int x, int y, int* row, int* column,
|
||||||
|
int PosType = CHARACTER_POS) const;
|
||||||
|
void maintain_absolute_top_line_number(int state);
|
||||||
|
int get_absolute_top_line_number() const;
|
||||||
|
void absolute_top_line_number(int oldFirstChar);
|
||||||
|
int maintaining_absolute_top_line_number() const;
|
||||||
|
void reset_absolute_top_line_number();
|
||||||
|
int position_to_linecol(int pos, int* lineNum, int* column) const;
|
||||||
|
int 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) const;
|
||||||
|
void find_line_end(int pos, bool start_pos_is_text_start, int *lineEnd,
|
||||||
|
int *nextLineStart) const;
|
||||||
|
double measure_proportional_character(const char *s, int colNum, int pos) const;
|
||||||
|
int wrap_uses_character(int lineEndPos) const;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
/** Gets the default font used when drawing text in the widget. */
|
int damage_range1_start, damage_range1_end;
|
||||||
Fl_Font textfont() const {return textfont_;}
|
int damage_range2_start, damage_range2_end;
|
||||||
/** Sets the default font used when drawing text in the widget. */
|
int mCursorPos;
|
||||||
void textfont(Fl_Font s) {textfont_ = s;}
|
int mCursorOn;
|
||||||
/** Gets the default size of text in the widget. */
|
int mCursorOldY; /* Y pos. of cursor for blanking */
|
||||||
Fl_Fontsize textsize() const {return textsize_;}
|
int mCursorToHint; /* Tells the buffer modified callback
|
||||||
/** Sets the default size of text in the widget. */
|
where to move the cursor, to reduce
|
||||||
void textsize(Fl_Fontsize s) {textsize_ = s;}
|
the number of redraw calls */
|
||||||
/** Gets the default color of text in the widget. */
|
int mCursorStyle; /* One of enum cursorStyles above */
|
||||||
Fl_Color textcolor() const {return textcolor_;}
|
int mCursorPreferredXPos; /* Pixel position for vert. cursor movement */
|
||||||
/** Sets the default color of text in the widget. */
|
int mNVisibleLines; /* # of visible (displayed) lines */
|
||||||
void textcolor(Fl_Color n) {textcolor_ = n;}
|
int mNBufferLines; /* # of newlines in the buffer */
|
||||||
|
Fl_Text_Buffer_mod* mBuffer; /* Contains text to be displayed */
|
||||||
int wrapped_column(int row, int column) const;
|
Fl_Text_Buffer_mod* mStyleBuffer; /* Optional parallel buffer containing
|
||||||
int wrapped_row(int row) const;
|
color and font information */
|
||||||
void wrap_mode(int wrap, int wrap_margin);
|
int mFirstChar, mLastChar; /* Buffer positions of first and last
|
||||||
|
displayed character (lastChar points
|
||||||
virtual void resize(int X, int Y, int W, int H);
|
either to a newline or one character
|
||||||
|
beyond the end of the buffer) */
|
||||||
protected:
|
int mContinuousWrap; /* Wrap long lines when displaying */
|
||||||
// Most (all?) of this stuff should only be called from resize() or
|
int mFastDisplay; /* force continuous wrap and insertion of eol characters
|
||||||
// draw().
|
used in FTextRX */
|
||||||
// Anything with "vline" indicates thats it deals with currently
|
std::string s_text; /* current contents of line text buffer */
|
||||||
// visible lines.
|
std::string s_style; /* current contents of line stype buffer */
|
||||||
|
int mWrapMarginPix; /* Margin in # of pixels for
|
||||||
virtual void draw();
|
wrapping in continuousWrap mode */
|
||||||
void draw_text(int X, int Y, int W, int H);
|
int* mLineStarts;
|
||||||
void draw_range(int start, int end);
|
int mTopLineNum; /* Line number of top displayed line
|
||||||
void draw_cursor(int, int);
|
of file (first line of file is 1) */
|
||||||
|
int mAbsTopLineNum; /* In continuous wrap mode, the line
|
||||||
void draw_string(int style, int x, int y, int toX, const char *string,
|
number of the top line if the text
|
||||||
int nChars);
|
were not wrapped (note that this is
|
||||||
|
only maintained as needed). */
|
||||||
void draw_vline(int visLineNum, int leftClip, int rightClip,
|
int mNeedAbsTopLineNum; /* Externally settable flag to continue
|
||||||
int leftCharIndex, int rightCharIndex);
|
maintaining absTopLineNum even if
|
||||||
|
it isn't needed for line # display */
|
||||||
void draw_line_numbers(bool clearAll);
|
int mHorizOffset; /* Horizontal scroll pos. in pixels */
|
||||||
|
int mTopLineNumHint; /* Line number of top displayed line
|
||||||
void clear_rect(int style, int x, int y, int width, int height);
|
of file (first line of file is 1) */
|
||||||
void display_insert();
|
int mHorizOffsetHint; /* Horizontal scroll pos. in pixels */
|
||||||
|
int mNStyles; /* Number of entries in styleTable */
|
||||||
void offset_line_starts(int newTopLineNum);
|
const Style_Table_Entry *mStyleTable; /* Table of fonts and colors for
|
||||||
|
coloring/syntax-highlighting */
|
||||||
void calc_line_starts(int startLine, int endLine);
|
char mUnfinishedStyle; /* Style buffer entry which triggers
|
||||||
|
on-the-fly reparsing of region */
|
||||||
void update_line_starts(int pos, int charsInserted, int charsDeleted,
|
Unfinished_Style_Cb mUnfinishedHighlightCB; /* Callback to parse "unfinished" */
|
||||||
int linesInserted, int linesDeleted, int *scrolled);
|
/* regions */
|
||||||
|
void* mHighlightCBArg; /* Arg to unfinishedHighlightCB */
|
||||||
void calc_last_char();
|
|
||||||
|
int mMaxsize;
|
||||||
int position_to_line( size_t pos, int* lineNum ) const;
|
|
||||||
int string_width(const char* string, int length, int style) const;
|
int mSuppressResync; /* Suppress resynchronization of line
|
||||||
|
starts during buffer updates */
|
||||||
static void scroll_timer_cb(void*);
|
int mNLinesDeleted; /* Number of lines deleted during
|
||||||
|
buffer modification (only used
|
||||||
static void buffer_predelete_cb(int pos, int nDeleted, void* cbArg);
|
when resynchronization is suppressed) */
|
||||||
static void buffer_modified_cb(int pos, int nInserted, int nDeleted,
|
int mModifyingTabDistance; /* Whether tab distance is being
|
||||||
int nRestyled, const char* deletedText,
|
modified */
|
||||||
void* cbArg);
|
|
||||||
|
mutable double mColumnScale; /* Width in pixels of an average character. This
|
||||||
static void h_scrollbar_cb(Fl_Scrollbar* w, Fl_Text_Display_mod* d);
|
value is calculated as needed (lazy eval); it
|
||||||
static void v_scrollbar_cb( Fl_Scrollbar* w, Fl_Text_Display_mod* d);
|
needs to be mutable so that it can be calculated
|
||||||
void update_v_scrollbar();
|
within a method marked as "const" */
|
||||||
void update_h_scrollbar();
|
|
||||||
int measure_vline(int visLineNum) const;
|
Fl_Color mCursor_color;
|
||||||
int longest_vline() const;
|
|
||||||
int empty_vlines() const;
|
Fl_Scrollbar* mHScrollBar;
|
||||||
int vline_length(int visLineNum) const;
|
Fl_Scrollbar* mVScrollBar;
|
||||||
int xy_to_position(int x, int y, int PosType = CHARACTER_POS) const;
|
int scrollbar_width_;
|
||||||
|
Fl_Align scrollbar_align_;
|
||||||
void xy_to_rowcol(int x, int y, int* row, int* column,
|
int dragPos, dragType, dragging;
|
||||||
int PosType = CHARACTER_POS) const;
|
int display_insert_position_hint;
|
||||||
|
struct { int x, y, w, h; } text_area;
|
||||||
int position_to_xy(int pos, int* x, int* y) const;
|
|
||||||
void maintain_absolute_top_line_number(int state);
|
int shortcut_;
|
||||||
int get_absolute_top_line_number() const;
|
|
||||||
void absolute_top_line_number(int oldFirstChar);
|
Fl_Font textfont_;
|
||||||
int maintaining_absolute_top_line_number() const;
|
Fl_Fontsize textsize_;
|
||||||
void reset_absolute_top_line_number();
|
Fl_Color textcolor_;
|
||||||
int position_to_linecol(int pos, int* lineNum, int* column) const;
|
|
||||||
void scroll_(int topLineNum, int horizOffset);
|
// The following are not presently used from the original NEdit code,
|
||||||
|
// but are being put here so that future versions of Fl_Text_Display_mod
|
||||||
void extend_range_for_styles(int* start, int* end);
|
// can implement line numbers without breaking binary compatibility.
|
||||||
|
|
||||||
void find_wrap_range(const char *deletedText, int pos, int nInserted,
|
/* Line number margin and width */
|
||||||
int nDeleted, int *modRangeStart, int *modRangeEnd,
|
int mLineNumLeft, mLineNumWidth;
|
||||||
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) const;
|
|
||||||
void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd,
|
|
||||||
int *nextLineStart) const;
|
|
||||||
int measure_proportional_character(char c, int colNum, int pos) const;
|
|
||||||
int wrap_uses_character(int lineEndPos) const;
|
|
||||||
int range_touches_selection(const Fl_Text_Selection *sel, int rangeStart,
|
|
||||||
int rangeEnd) const;
|
|
||||||
#ifndef FL_DOXYGEN
|
|
||||||
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;
|
|
||||||
|
|
||||||
int shortcut_;
|
|
||||||
|
|
||||||
Fl_Font textfont_;
|
|
||||||
Fl_Fontsize textsize_;
|
|
||||||
Fl_Color 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
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_Text_Display.H 6902 2009-09-27 11:06:56Z matt $".
|
// End of "$Id: Fl_Text_Display_mod.H 8306 2011-01-24 17:04:22Z matt $".
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
//
|
//
|
||||||
// "$Id: Fl_Text_Editor.H 6893 2009-09-20 19:24:24Z greg.ercolano $"
|
// "$Id: Fl_Text_Editor_mod.H 7903 2010-11-28 21:06:39Z matt $"
|
||||||
//
|
//
|
||||||
// Header file for Fl_Text_Editor class.
|
// Header file for Fl_Text_Editor_mod class.
|
||||||
//
|
//
|
||||||
// Copyright 2001-2009 by Bill Spitzak and others.
|
// Copyright 2001-2010 by Bill Spitzak and others.
|
||||||
// Original code Copyright Mark Edel. Permission to distribute under
|
// Original code Copyright Mark Edel. Permission to distribute under
|
||||||
// the LGPL for the FLTK library granted by Mark Edel.
|
// the LGPL for the FLTK library granted by Mark Edel.
|
||||||
//
|
//
|
||||||
|
@ -28,22 +28,22 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
/* \file
|
/* \file
|
||||||
Fl_Text_Editor widget . */
|
Fl_Text_Editor_mod widget . */
|
||||||
|
|
||||||
|
|
||||||
#ifndef FL_TEXT_EDITOR_H
|
#ifndef Fl_Text_Editor_mod_H
|
||||||
#define FL_TEXT_EDITOR_H
|
#define Fl_Text_Editor_mod_H
|
||||||
|
|
||||||
#include "Fl_Text_Display_mod.H"
|
#include "Fl_Text_Display_mod.H"
|
||||||
|
|
||||||
// key will match in any state
|
// key will match in any state
|
||||||
#define FL_TEXT_EDITOR_ANY_STATE (-1L)
|
#define Fl_Text_Editor_mod_ANY_STATE (-1L)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is the FLTK text editor widget. It allows the user to
|
This is the FLTK text editor widget. It allows the user to
|
||||||
edit multiple lines of text and supports highlighting and
|
edit multiple lines of text and supports highlighting and
|
||||||
scrolling. The buffer that is displayed in the widget is managed
|
scrolling. The buffer that is displayed in the widget is managed
|
||||||
by the Fl_Text_Buffer
|
by the Fl_Text_Buffer_mod
|
||||||
class.
|
class.
|
||||||
*/
|
*/
|
||||||
class FL_EXPORT Fl_Text_Editor_mod : public Fl_Text_Display_mod {
|
class FL_EXPORT Fl_Text_Editor_mod : public Fl_Text_Display_mod {
|
||||||
|
@ -136,6 +136,6 @@ class FL_EXPORT Fl_Text_Editor_mod : public Fl_Text_Display_mod {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_Text_Editor.H 6893 2009-09-20 19:24:24Z greg.ercolano $".
|
// End of "$Id: Fl_Text_Editor_mod.H 7903 2010-11-28 21:06:39Z matt $".
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,24 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.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 FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3
|
||||||
|
# undef dirent
|
||||||
|
# include <dirent.h>
|
||||||
|
# else
|
||||||
|
# include <dirent.h>
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <dirent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
|
@ -1,34 +1,18 @@
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// fileselect.h
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2009
|
|
||||||
// Stelios Bounanos, M0GLD
|
|
||||||
//
|
|
||||||
// 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. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with fldigi. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef FILESELECT_H
|
#ifndef FILESELECT_H
|
||||||
#define FILESELECT_H
|
#define FILESELECT_H
|
||||||
|
|
||||||
#ifdef __WOE32__
|
#include <config.h>
|
||||||
# define FSEL_THREAD 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#if (FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3) || (FLARQ_FLTK_API_MAJOR == 1 && FLARQ_FLTK_API_MINOR < 3)
|
||||||
|
//#ifdef __WIN32__
|
||||||
|
//# define FSEL_THREAD 1
|
||||||
|
//#endif
|
||||||
|
#define FSEL_THREAD 0
|
||||||
class Fl_Native_File_Chooser;
|
class Fl_Native_File_Chooser;
|
||||||
|
#else
|
||||||
|
#include <FL/Fl_Native_File_Chooser.H>
|
||||||
|
#define FSEL_THREAD 0
|
||||||
|
#endif
|
||||||
|
|
||||||
class FSEL
|
class FSEL
|
||||||
{
|
{
|
||||||
|
|
15
src/main.cxx
15
src/main.cxx
|
@ -47,9 +47,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifndef __MINGW32__
|
|
||||||
# include <dirent.h>
|
|
||||||
#endif
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
@ -63,10 +61,17 @@
|
||||||
# define dirent fl_dirent_no_thanks
|
# define dirent fl_dirent_no_thanks
|
||||||
#endif
|
#endif
|
||||||
#include <FL/filename.H>
|
#include <FL/filename.H>
|
||||||
#ifdef __MINGW32__
|
|
||||||
# undef dirent
|
#ifdef __WOE32__
|
||||||
|
# if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3
|
||||||
|
# undef dirent
|
||||||
|
# include <dirent.h>
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "waterfall.h"
|
#include "waterfall.h"
|
||||||
|
|
|
@ -68,6 +68,23 @@
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// 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 FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3
|
||||||
|
# undef dirent
|
||||||
|
# include <dirent.h>
|
||||||
|
# else
|
||||||
|
# include <dirent.h>
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include <dirent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -70,12 +70,12 @@ struct CMDS { std::string cmd; void (*fp)(std::string); };
|
||||||
static queue<CMDS> cmds;
|
static queue<CMDS> cmds;
|
||||||
|
|
||||||
// following used for debugging and development
|
// following used for debugging and development
|
||||||
//void pushcmd(CMDS cmd)
|
void pushcmd(CMDS cmd)
|
||||||
//{
|
{
|
||||||
// LOG_INFO("%s, # = %d", cmd.cmd.c_str(), (int)cmds.size());
|
LOG_INFO("%s, # = %d", cmd.cmd.c_str(), (int)cmds.size());
|
||||||
// cmds.push(cmd);
|
cmds.push(cmd);
|
||||||
//}
|
}
|
||||||
#define pushcmd(a) cmds.push((a))
|
//#define pushcmd(a) cmds.push((a))
|
||||||
|
|
||||||
// these variables are referenced outside of this file
|
// these variables are referenced outside of this file
|
||||||
MACROTEXT macros;
|
MACROTEXT macros;
|
||||||
|
@ -670,7 +670,7 @@ static void pZD(std::string &s, size_t &i, size_t endbracket)
|
||||||
s.replace( i, 4, szDt);
|
s.replace( i, 4, szDt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pID(std::string &s, size_t &i, size_t endbracket)
|
static void p_ID(std::string &s, size_t &i, size_t endbracket)
|
||||||
{
|
{
|
||||||
if (within_exec) {
|
if (within_exec) {
|
||||||
s.replace(i, endbracket - i + 1, "");
|
s.replace(i, endbracket - i + 1, "");
|
||||||
|
@ -1833,7 +1833,8 @@ bool queue_must_rx()
|
||||||
static std::string rxcmds = "<!MOD<!WAI<!GOH<!QSY<!GOF";
|
static std::string rxcmds = "<!MOD<!WAI<!GOH<!QSY<!GOF";
|
||||||
if (cmds.empty()) return false;
|
if (cmds.empty()) return false;
|
||||||
CMDS cmd = cmds.front();
|
CMDS cmd = cmds.front();
|
||||||
return (rxcmds.find(cmd.cmd.substr(0,5)) != std::string::npos);
|
bool ret = (rxcmds.find(cmd.cmd.substr(0,5)) != std::string::npos);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MTAGS { const char *mTAG; void (*fp)(std::string &, size_t&, size_t );};
|
struct MTAGS { const char *mTAG; void (*fp)(std::string &, size_t&, size_t );};
|
||||||
|
@ -1862,7 +1863,7 @@ static const MTAGS mtags[] = {
|
||||||
{"<ZT>", pZT},
|
{"<ZT>", pZT},
|
||||||
{"<LD>", pLD},
|
{"<LD>", pLD},
|
||||||
{"<ZD>", pZD},
|
{"<ZD>", pZD},
|
||||||
{"<ID>", pID},
|
{"<ID>", p_ID},
|
||||||
{"<TEXT>", pTEXT},
|
{"<TEXT>", pTEXT},
|
||||||
{"<CWID>", pCWID},
|
{"<CWID>", pCWID},
|
||||||
{"<RX>", pRX},
|
{"<RX>", pRX},
|
||||||
|
@ -2016,7 +2017,7 @@ void MACROTEXT::openMacroFile()
|
||||||
{
|
{
|
||||||
std::string deffilename = MacrosDir;
|
std::string deffilename = MacrosDir;
|
||||||
deffilename.append(progStatus.LastMacroFile);
|
deffilename.append(progStatus.LastMacroFile);
|
||||||
const char *p = FSEL::select(_("Open macro file"), _("Fldigi macro definition file\t*.mdf"), deffilename.c_str());
|
const char *p = FSEL::select(_("Open macro file"), _("Fldigi macro definition file\t*.{mdf}"), deffilename.c_str());
|
||||||
if (p) {
|
if (p) {
|
||||||
loadMacros(p);
|
loadMacros(p);
|
||||||
progStatus.LastMacroFile = fl_filename_name(p);
|
progStatus.LastMacroFile = fl_filename_name(p);
|
||||||
|
@ -2028,10 +2029,15 @@ void MACROTEXT::saveMacroFile()
|
||||||
{
|
{
|
||||||
std::string deffilename = MacrosDir;
|
std::string deffilename = MacrosDir;
|
||||||
deffilename.append(progStatus.LastMacroFile);
|
deffilename.append(progStatus.LastMacroFile);
|
||||||
const char *p = FSEL::saveas(_("Save macro file"), _("Fldigi macro definition file\t*.mdf"), deffilename.c_str());
|
const char *p = FSEL::saveas(
|
||||||
|
_("Save macro file"),
|
||||||
|
_("Fldigi macro definition file\t*.{mdf}"),
|
||||||
|
deffilename.c_str());
|
||||||
if (p) {
|
if (p) {
|
||||||
saveMacros(p);
|
string sp = p;
|
||||||
progStatus.LastMacroFile = fl_filename_name(p);
|
if (sp.rfind(".mdf") == string::npos) sp.append(".mdf");
|
||||||
|
saveMacros(sp.c_str());
|
||||||
|
progStatus.LastMacroFile = fl_filename_name(sp.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,9 @@ FTextRX::FTextRX(int x, int y, int w, int h, const char *l)
|
||||||
init_context_menu();
|
init_context_menu();
|
||||||
menu[RX_MENU_QUICK_ENTRY].clear();
|
menu[RX_MENU_QUICK_ENTRY].clear();
|
||||||
menu[RX_MENU_SCROLL_HINTS].clear();
|
menu[RX_MENU_SCROLL_HINTS].clear();
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
menu[RX_MENU_WRAP].hide();
|
||||||
|
#endif
|
||||||
// Replace the scrollbar widget
|
// Replace the scrollbar widget
|
||||||
MVScrollbar* mvsb = new MVScrollbar(mVScrollBar->x(), mVScrollBar->y(),
|
MVScrollbar* mvsb = new MVScrollbar(mVScrollBar->x(), mVScrollBar->y(),
|
||||||
mVScrollBar->w(), mVScrollBar->h(), NULL);
|
mVScrollBar->w(), mVScrollBar->h(), NULL);
|
||||||
|
@ -152,6 +154,9 @@ FTextRX::FTextRX(int x, int y, int w, int h, const char *l)
|
||||||
remove(mVScrollBar);
|
remove(mVScrollBar);
|
||||||
delete mVScrollBar;
|
delete mVScrollBar;
|
||||||
Fl_Group::add(mVScrollBar = mvsb);
|
Fl_Group::add(mVScrollBar = mvsb);
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
mFastDisplay = 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
FTextRX::~FTextRX()
|
FTextRX::~FTextRX()
|
||||||
|
@ -209,7 +214,11 @@ int FTextRX::handle(int event)
|
||||||
}
|
}
|
||||||
case FL_MOVE: {
|
case FL_MOVE: {
|
||||||
int p = xy_to_position(Fl::event_x(), Fl::event_y(), Fl_Text_Display_mod::CURSOR_POS);
|
int p = xy_to_position(Fl::event_x(), Fl::event_y(), Fl_Text_Display_mod::CURSOR_POS);
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
if (sbuf->char_at(p) >= CLICK_START + FTEXT_DEF) {
|
||||||
|
#else
|
||||||
if (sbuf->character(p) >= CLICK_START + FTEXT_DEF) {
|
if (sbuf->character(p) >= CLICK_START + FTEXT_DEF) {
|
||||||
|
#endif
|
||||||
if (cursor != FL_CURSOR_HAND)
|
if (cursor != FL_CURSOR_HAND)
|
||||||
window()->cursor(cursor = FL_CURSOR_HAND);
|
window()->cursor(cursor = FL_CURSOR_HAND);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -248,6 +257,99 @@ out:
|
||||||
/// @param c The character
|
/// @param c The character
|
||||||
/// @param attr The attribute (@see enum text_attr_e); RECV if omitted.
|
/// @param attr The attribute (@see enum text_attr_e); RECV if omitted.
|
||||||
///
|
///
|
||||||
|
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
void FTextRX::add(unsigned char c, int attr)
|
||||||
|
{
|
||||||
|
if (c == '\r')
|
||||||
|
return;
|
||||||
|
|
||||||
|
char s[] = { '\0', '\0', FTEXT_DEF + attr, '\0' };
|
||||||
|
const char *cp = &s[0];
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
if (s_text.length()) {
|
||||||
|
s_text.erase(s_text.end() - 1);
|
||||||
|
s_style.erase(s_style.end() - 1);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
s_text.clear();
|
||||||
|
s_style.clear();
|
||||||
|
insert("\n");
|
||||||
|
sbuf->append(s + 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if ((c < ' ' || c == 127) && attr != CTRL) // look it up
|
||||||
|
cp = ascii[(unsigned char)c];
|
||||||
|
else // insert verbatim
|
||||||
|
s[0] = c;
|
||||||
|
|
||||||
|
for (int i = 0; cp[i]; ++i) {
|
||||||
|
s_text += cp[i];
|
||||||
|
s_style += s[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
fl_font( textfont(), textsize() );
|
||||||
|
int lwidth = (int)fl_width( s_text.c_str(), s_text.length());
|
||||||
|
bool wrapped = false;
|
||||||
|
if ( lwidth >= (text_area.w - mVScrollBar->w() - LEFT_MARGIN - RIGHT_MARGIN)) {
|
||||||
|
if (c != ' ') {
|
||||||
|
size_t p = s_text.rfind(' ');
|
||||||
|
if (p != string::npos) {
|
||||||
|
s_text.erase(0, p+1);
|
||||||
|
s_style.erase(0, p+1);
|
||||||
|
if (s_text.length() < 10) { // wrap and delete trailing space
|
||||||
|
tbuf->remove(tbuf->length() - s_text.length(), tbuf->length());
|
||||||
|
sbuf->remove(sbuf->length() - s_style.length(), sbuf->length());
|
||||||
|
insert("\n"); // always insert new line
|
||||||
|
sbuf->append(s + 2);
|
||||||
|
insert(s_text.c_str());
|
||||||
|
sbuf->append(s_style.c_str());
|
||||||
|
wrapped = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!wrapped) { // add a new line if not wrapped
|
||||||
|
insert("\n");
|
||||||
|
sbuf->append(s + 2);
|
||||||
|
if (c != ' ') { // add character if not a space (no leading spaces)
|
||||||
|
for (int i = 0; cp[i]; ++i)
|
||||||
|
sbuf->append(s + 2);
|
||||||
|
insert(cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s_text.clear();
|
||||||
|
s_style.clear();
|
||||||
|
} else {
|
||||||
|
for (int i = 0; cp[i]; ++i)
|
||||||
|
sbuf->append(s + 2);
|
||||||
|
insert(cp);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// test for bottom of text visibility
|
||||||
|
if (// !mFastDisplay &&
|
||||||
|
(mVScrollBar->value() >= mNBufferLines - mNVisibleLines + mVScrollBar->linesize() - 1))
|
||||||
|
show_insert_position();
|
||||||
|
}
|
||||||
|
#else
|
||||||
void FTextRX::add(unsigned char c, int attr)
|
void FTextRX::add(unsigned char c, int attr)
|
||||||
{
|
{
|
||||||
if (c == '\r')
|
if (c == '\r')
|
||||||
|
@ -288,7 +390,11 @@ void FTextRX::add(unsigned char c, int attr)
|
||||||
insert(cp);
|
insert(cp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// test for bottom of text visibility
|
||||||
|
if (mVScrollBar->value() >= mNBufferLines - mNVisibleLines + mVScrollBar->linesize() - 1)
|
||||||
|
show_insert_position();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void FTextRX::set_quick_entry(bool b)
|
void FTextRX::set_quick_entry(bool b)
|
||||||
{
|
{
|
||||||
|
@ -317,6 +423,10 @@ void FTextRX::mark(FTextBase::TEXT_ATTR attr)
|
||||||
void FTextRX::clear(void)
|
void FTextRX::clear(void)
|
||||||
{
|
{
|
||||||
FTextBase::clear();
|
FTextBase::clear();
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
s_text.clear();
|
||||||
|
s_style.clear();
|
||||||
|
#endif
|
||||||
static_cast<MVScrollbar*>(mVScrollBar)->clear();
|
static_cast<MVScrollbar*>(mVScrollBar)->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,21 +438,38 @@ void FTextRX::setFont(Fl_Font f, int attr)
|
||||||
|
|
||||||
void FTextRX::handle_clickable(int x, int y)
|
void FTextRX::handle_clickable(int x, int y)
|
||||||
{
|
{
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
int pos;
|
||||||
|
unsigned int style;
|
||||||
|
#else
|
||||||
int pos, style;
|
int pos, style;
|
||||||
|
#endif
|
||||||
|
|
||||||
pos = xy_to_position(x + this->x(), y + this->y(), CURSOR_POS);
|
pos = xy_to_position(x + this->x(), y + this->y(), CURSOR_POS);
|
||||||
// return unless clickable style
|
// return unless clickable style
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
if ((style = sbuf->char_at(pos)) < CLICK_START + FTEXT_DEF)
|
||||||
|
#else
|
||||||
if ((style = sbuf->character(pos)) < CLICK_START + FTEXT_DEF)
|
if ((style = sbuf->character(pos)) < CLICK_START + FTEXT_DEF)
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int start, end;
|
int start, end;
|
||||||
for (start = pos-1; start >= 0; start--)
|
for (start = pos-1; start >= 0; start--)
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
if (sbuf->char_at(start) != style)
|
||||||
|
#else
|
||||||
if (sbuf->character(start) != style)
|
if (sbuf->character(start) != style)
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
start++;
|
start++;
|
||||||
int len = sbuf->length();
|
int len = sbuf->length();
|
||||||
for (end = pos+1; end < len; end++)
|
for (end = pos+1; end < len; end++)
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
if (sbuf->char_at(end) != style)
|
||||||
|
#else
|
||||||
if (sbuf->character(end) != style)
|
if (sbuf->character(end) != style)
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (style - FTEXT_DEF) {
|
switch (style - FTEXT_DEF) {
|
||||||
|
@ -786,7 +913,11 @@ int FTextTX::nextChar(void)
|
||||||
else if (insert_position() <= txpos) // empty buffer or cursor inside transmitted text
|
else if (insert_position() <= txpos) // empty buffer or cursor inside transmitted text
|
||||||
c = -1;
|
c = -1;
|
||||||
else {
|
else {
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
if ((c = static_cast<unsigned char>(tbuf->char_at(txpos)))) {
|
||||||
|
#else
|
||||||
if ((c = static_cast<unsigned char>(tbuf->character(txpos)))) {
|
if ((c = static_cast<unsigned char>(tbuf->character(txpos)))) {
|
||||||
|
#endif
|
||||||
++txpos;
|
++txpos;
|
||||||
REQ(FTextTX::changed_cb, txpos, 0, 0, -1,
|
REQ(FTextTX::changed_cb, txpos, 0, 0, -1,
|
||||||
static_cast<const char *>(0), this);
|
static_cast<const char *>(0), this);
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
|
|
||||||
#include "FTextView.h"
|
#include "FTextView.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,6 +194,17 @@ void FTextBase::resize(int X, int Y, int W, int H)
|
||||||
if (need_wrap_reset)
|
if (need_wrap_reset)
|
||||||
reset_wrap_col();
|
reset_wrap_col();
|
||||||
|
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
TOP_MARGIN = DEFAULT_TOP_MARGIN;
|
||||||
|
int r = H - Fl::box_dh(box()) - TOP_MARGIN - BOTTOM_MARGIN;
|
||||||
|
if (mHScrollBar->visible())
|
||||||
|
r -= scrollbar_width();
|
||||||
|
int msize = mMaxsize ? mMaxsize : textsize();
|
||||||
|
if (!msize) msize = 1;
|
||||||
|
//printf("H %d, textsize %d, lines %d, extra %d\n", r, msize, r / msize, r % msize);
|
||||||
|
if (r %= msize)
|
||||||
|
TOP_MARGIN += r;
|
||||||
|
#else
|
||||||
if (need_margin_reset && textsize() > 0) {
|
if (need_margin_reset && textsize() > 0) {
|
||||||
TOP_MARGIN = DEFAULT_TOP_MARGIN;
|
TOP_MARGIN = DEFAULT_TOP_MARGIN;
|
||||||
int r = H - Fl::box_dh(box()) - TOP_MARGIN - BOTTOM_MARGIN;
|
int r = H - Fl::box_dh(box()) - TOP_MARGIN - BOTTOM_MARGIN;
|
||||||
|
@ -200,13 +213,13 @@ void FTextBase::resize(int X, int Y, int W, int H)
|
||||||
if (r %= textsize())
|
if (r %= textsize())
|
||||||
TOP_MARGIN += r;
|
TOP_MARGIN += r;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (scroll_hint) {
|
if (scroll_hint) {
|
||||||
mTopLineNumHint = mNBufferLines;
|
mTopLineNumHint = mNBufferLines;
|
||||||
mHorizOffsetHint = 0;
|
mHorizOffsetHint = 0;
|
||||||
// display_insert_position_hint = 1;
|
// display_insert_position_hint = 1;
|
||||||
scroll_hint = false;
|
scroll_hint = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hscroll_visible = mHScrollBar->visible();
|
bool hscroll_visible = mHScrollBar->visible();
|
||||||
Fl_Text_Editor_mod::resize(X, Y, W, H);
|
Fl_Text_Editor_mod::resize(X, Y, W, H);
|
||||||
|
@ -285,6 +298,8 @@ void FTextBase::set_style(int attr, Fl_Font f, int s, Fl_Color c, int set)
|
||||||
/// @return 0 on success, -1 on error
|
/// @return 0 on success, -1 on error
|
||||||
int FTextBase::readFile(const char* fn)
|
int FTextBase::readFile(const char* fn)
|
||||||
{
|
{
|
||||||
|
set_word_wrap(restore_wrap);
|
||||||
|
|
||||||
if ( !(fn || (fn = FSEL::select(_("Insert text"), "Text\t*.txt"))) )
|
if ( !(fn || (fn = FSEL::select(_("Insert text"), "Text\t*.txt"))) )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -393,6 +408,10 @@ char* FTextBase::get_word(int x, int y, const char* nwchars, bool ontext)
|
||||||
return tbuf->selection_text();
|
return tbuf->selection_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3
|
||||||
|
start = tbuf->word_start(p);
|
||||||
|
end = tbuf->word_end(p);
|
||||||
|
#else
|
||||||
string nonword = nwchars;
|
string nonword = nwchars;
|
||||||
nonword.append(" \t\n");
|
nonword.append(" \t\n");
|
||||||
if (!tbuf->findchars_backward(p, nonword.c_str(), &start))
|
if (!tbuf->findchars_backward(p, nonword.c_str(), &start))
|
||||||
|
@ -401,6 +420,7 @@ char* FTextBase::get_word(int x, int y, const char* nwchars, bool ontext)
|
||||||
start++;
|
start++;
|
||||||
if (!tbuf->findchars_forward(p, nonword.c_str(), &end))
|
if (!tbuf->findchars_forward(p, nonword.c_str(), &end))
|
||||||
end = tbuf->length();
|
end = tbuf->length();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ontext && (p < start || p >= end))
|
if (ontext && (p < start || p >= end))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -775,35 +795,32 @@ int FTextEdit::handle_dnd_drag(int pos)
|
||||||
/// @return 1 or FTextBase::handle(FL_PASTE)
|
/// @return 1 or FTextBase::handle(FL_PASTE)
|
||||||
int FTextEdit::handle_dnd_drop(void)
|
int FTextEdit::handle_dnd_drop(void)
|
||||||
{
|
{
|
||||||
restore_wrap = wrap;
|
// paste verbatim if the shift key was held down during dnd
|
||||||
set_word_wrap(false);
|
|
||||||
|
|
||||||
if (Fl::event_shift())
|
if (Fl::event_shift())
|
||||||
return FTextBase::handle(FL_PASTE);
|
return FTextBase::handle(FL_PASTE);
|
||||||
|
|
||||||
#if !defined(__APPLE__) && !defined(__WOE32__)
|
string text;
|
||||||
if (strncmp(Fl::event_text(), "file://", 7))
|
string::size_type p, len;
|
||||||
return FTextBase::handle(FL_PASTE);
|
|
||||||
#endif
|
text = Fl::event_text();
|
||||||
|
|
||||||
string text = Fl::event_text();
|
|
||||||
#if defined(__APPLE__) || defined(__WOE32__)
|
|
||||||
const char sep[] = "\n";
|
const char sep[] = "\n";
|
||||||
|
#if defined(__APPLE__) || defined(__WOE32__)
|
||||||
text += sep;
|
text += sep;
|
||||||
#else
|
|
||||||
const char sep[] = "\r\n";
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string::size_type p, len = text.length();
|
len = text.length();
|
||||||
while ((p = text.find(sep)) != string::npos) {
|
while ((p = text.find(sep)) != string::npos) {
|
||||||
text[p] = '\0';
|
text[p] = '\0';
|
||||||
#if !defined(__APPLE__) && !defined(__WOE32__)
|
#if !defined(__APPLE__) && !defined(__WOE32__)
|
||||||
if (text.find("file://") == 0) {
|
if (text.find("file://") == 0) {
|
||||||
text.erase(0, 7);
|
text.erase(0, 7);
|
||||||
p -= 7;
|
p -= 7;
|
||||||
|
len -= 7;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// paste everything verbatim if we couldn't read the first file
|
// paste everything verbatim if we cannot read the first file
|
||||||
|
LOG_INFO("DnD file %s", text.c_str());
|
||||||
if (readFile(text.c_str()) == -1 && len == text.length())
|
if (readFile(text.c_str()) == -1 && len == text.length())
|
||||||
return FTextBase::handle(FL_PASTE);
|
return FTextBase::handle(FL_PASTE);
|
||||||
text.erase(0, p + sizeof(sep) - 1);
|
text.erase(0, p + sizeof(sep) - 1);
|
||||||
|
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// "$Id: Fl_Text_Editor.cxx 7462 2010-04-06 23:00:56Z matt $"
|
// "$Id: Fl_Text_Editor_mod.cxx 8034 2010-12-15 12:21:55Z AlbrechtS $"
|
||||||
//
|
//
|
||||||
// Copyright 2001-2009 by Bill Spitzak and others.
|
// Copyright 2001-2010 by Bill Spitzak and others.
|
||||||
// Original code Copyright Mark Edel. Permission to distribute under
|
// Original code Copyright Mark Edel. Permission to distribute under
|
||||||
// the LGPL for the FLTK library granted by Mark Edel.
|
// the LGPL for the FLTK library granted by Mark Edel.
|
||||||
//
|
//
|
||||||
|
@ -31,8 +31,8 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <FL/Fl.H>
|
#include <FL/Fl.H>
|
||||||
#include <FL/Fl_Window.H>
|
#include <FL/Fl_Window.H>
|
||||||
#include "Fl_Text_Editor_mod.H"
|
|
||||||
#include <FL/fl_ask.H>
|
#include <FL/fl_ask.H>
|
||||||
|
#include "Fl_Text_Editor_mod.H"
|
||||||
|
|
||||||
|
|
||||||
/* Keyboard Control Matrix
|
/* Keyboard Control Matrix
|
||||||
|
@ -100,12 +100,12 @@ static struct {
|
||||||
int state;
|
int state;
|
||||||
Fl_Text_Editor_mod::Key_Func func;
|
Fl_Text_Editor_mod::Key_Func func;
|
||||||
} default_key_bindings[] = {
|
} default_key_bindings[] = {
|
||||||
{ FL_Escape, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_ignore },
|
{ FL_Escape, Fl_Text_Editor_mod_ANY_STATE, Fl_Text_Editor_mod::kf_ignore },
|
||||||
{ FL_Enter, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_enter },
|
{ FL_Enter, Fl_Text_Editor_mod_ANY_STATE, Fl_Text_Editor_mod::kf_enter },
|
||||||
{ FL_KP_Enter, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_enter },
|
{ FL_KP_Enter, Fl_Text_Editor_mod_ANY_STATE, Fl_Text_Editor_mod::kf_enter },
|
||||||
{ FL_BackSpace, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_backspace },
|
{ FL_BackSpace, Fl_Text_Editor_mod_ANY_STATE, Fl_Text_Editor_mod::kf_backspace },
|
||||||
{ FL_Insert, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_insert },
|
{ FL_Insert, Fl_Text_Editor_mod_ANY_STATE, Fl_Text_Editor_mod::kf_insert },
|
||||||
{ FL_Delete, FL_TEXT_EDITOR_ANY_STATE, Fl_Text_Editor_mod::kf_delete },
|
{ FL_Delete, Fl_Text_Editor_mod_ANY_STATE, Fl_Text_Editor_mod::kf_delete },
|
||||||
{ FL_Home, 0, Fl_Text_Editor_mod::kf_move },
|
{ FL_Home, 0, Fl_Text_Editor_mod::kf_move },
|
||||||
{ FL_End, 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_Left, 0, Fl_Text_Editor_mod::kf_move },
|
||||||
|
@ -184,7 +184,7 @@ Fl_Text_Editor_mod::Key_Func Fl_Text_Editor_mod::bound_key_function(int key, int
|
||||||
Key_Binding* cur;
|
Key_Binding* cur;
|
||||||
for (cur = list; cur; cur = cur->next)
|
for (cur = list; cur; cur = cur->next)
|
||||||
if (cur->key == key)
|
if (cur->key == key)
|
||||||
if (cur->state == FL_TEXT_EDITOR_ANY_STATE || cur->state == state)
|
if (cur->state == Fl_Text_Editor_mod_ANY_STATE || cur->state == state)
|
||||||
break;
|
break;
|
||||||
if (!cur) return 0;
|
if (!cur) return 0;
|
||||||
return cur->function;
|
return cur->function;
|
||||||
|
@ -223,8 +223,6 @@ void Fl_Text_Editor_mod::add_key_binding(int key, int state, Key_Func function,
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define NORMAL_INPUT_MOVE 0
|
|
||||||
|
|
||||||
static void kill_selection(Fl_Text_Editor_mod* e) {
|
static void kill_selection(Fl_Text_Editor_mod* e) {
|
||||||
if (e->buffer()->selected()) {
|
if (e->buffer()->selected()) {
|
||||||
e->insert_position(e->buffer()->primary_selection()->start());
|
e->insert_position(e->buffer()->primary_selection()->start());
|
||||||
|
@ -234,6 +232,7 @@ static void kill_selection(Fl_Text_Editor_mod* e) {
|
||||||
|
|
||||||
/** Inserts the text associated with the key */
|
/** Inserts the text associated with the key */
|
||||||
int Fl_Text_Editor_mod::kf_default(int c, Fl_Text_Editor_mod* e) {
|
int Fl_Text_Editor_mod::kf_default(int c, Fl_Text_Editor_mod* e) {
|
||||||
|
// FIXME: this function is a mess! Fix this!
|
||||||
if (!c || (!isprint(c) && c != '\t')) return 0;
|
if (!c || (!isprint(c) && c != '\t')) return 0;
|
||||||
char s[2] = "\0";
|
char s[2] = "\0";
|
||||||
s[0] = (char)c;
|
s[0] = (char)c;
|
||||||
|
@ -253,13 +252,9 @@ int Fl_Text_Editor_mod::kf_ignore(int, Fl_Text_Editor_mod*) {
|
||||||
/** Does a backspace in the current buffer.*/
|
/** Does a backspace in the current buffer.*/
|
||||||
int Fl_Text_Editor_mod::kf_backspace(int, Fl_Text_Editor_mod* e) {
|
int Fl_Text_Editor_mod::kf_backspace(int, Fl_Text_Editor_mod* e) {
|
||||||
if (!e->buffer()->selected() && e->move_left()) {
|
if (!e->buffer()->selected() && e->move_left()) {
|
||||||
int l = 1;
|
int p1 = e->insert_position();
|
||||||
// FIXME: character is ucs-4
|
int p2 = e->buffer()->next_char(p1);
|
||||||
char c = e->buffer()->character(e->insert_position());
|
e->buffer()->select(p1, p2);
|
||||||
if (c & 0x80 && c & 0x40) {
|
|
||||||
l = fl_utf8len(c);
|
|
||||||
}
|
|
||||||
e->buffer()->select(e->insert_position(), e->insert_position()+l);
|
|
||||||
}
|
}
|
||||||
kill_selection(e);
|
kill_selection(e);
|
||||||
e->show_insert_position();
|
e->show_insert_position();
|
||||||
|
@ -286,6 +281,7 @@ int Fl_Text_Editor_mod::kf_move(int c, Fl_Text_Editor_mod* e) {
|
||||||
if (!selected)
|
if (!selected)
|
||||||
e->dragPos = e->insert_position();
|
e->dragPos = e->insert_position();
|
||||||
e->buffer()->unselect();
|
e->buffer()->unselect();
|
||||||
|
Fl::copy("", 0, 0);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case FL_Home:
|
case FL_Home:
|
||||||
e->insert_position(e->buffer()->line_start(e->insert_position()));
|
e->insert_position(e->buffer()->line_start(e->insert_position()));
|
||||||
|
@ -320,6 +316,11 @@ int Fl_Text_Editor_mod::kf_move(int c, Fl_Text_Editor_mod* e) {
|
||||||
int Fl_Text_Editor_mod::kf_shift_move(int c, Fl_Text_Editor_mod* e) {
|
int Fl_Text_Editor_mod::kf_shift_move(int c, Fl_Text_Editor_mod* e) {
|
||||||
kf_move(c, e);
|
kf_move(c, e);
|
||||||
fl_text_drag_me(e->insert_position(), e);
|
fl_text_drag_me(e->insert_position(), e);
|
||||||
|
char *copy = e->buffer()->selection_text();
|
||||||
|
if (copy) {
|
||||||
|
Fl::copy(copy, strlen(copy), 0);
|
||||||
|
free(copy);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/** Moves the current text cursor in the direction indicated by control key */
|
/** Moves the current text cursor in the direction indicated by control key */
|
||||||
|
@ -328,6 +329,7 @@ int Fl_Text_Editor_mod::kf_ctrl_move(int c, Fl_Text_Editor_mod* e) {
|
||||||
e->dragPos = e->insert_position();
|
e->dragPos = e->insert_position();
|
||||||
if (c != FL_Up && c != FL_Down) {
|
if (c != FL_Up && c != FL_Down) {
|
||||||
e->buffer()->unselect();
|
e->buffer()->unselect();
|
||||||
|
Fl::copy("", 0, 0);
|
||||||
e->show_insert_position();
|
e->show_insert_position();
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -367,6 +369,7 @@ int Fl_Text_Editor_mod::kf_meta_move(int c, Fl_Text_Editor_mod* e) {
|
||||||
e->dragPos = e->insert_position();
|
e->dragPos = e->insert_position();
|
||||||
if (c != FL_Up && c != FL_Down) {
|
if (c != FL_Up && c != FL_Down) {
|
||||||
e->buffer()->unselect();
|
e->buffer()->unselect();
|
||||||
|
Fl::copy("", 0, 0);
|
||||||
e->show_insert_position();
|
e->show_insert_position();
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -449,13 +452,9 @@ int Fl_Text_Editor_mod::kf_insert(int, Fl_Text_Editor_mod* e) {
|
||||||
/** Does a delete of selected text or the current character in the current buffer.*/
|
/** Does a delete of selected text or the current character in the current buffer.*/
|
||||||
int Fl_Text_Editor_mod::kf_delete(int, Fl_Text_Editor_mod* e) {
|
int Fl_Text_Editor_mod::kf_delete(int, Fl_Text_Editor_mod* e) {
|
||||||
if (!e->buffer()->selected()) {
|
if (!e->buffer()->selected()) {
|
||||||
int l = 1;
|
int p1 = e->insert_position();
|
||||||
// FIXME: character is ucs-4
|
int p2 = e->buffer()->next_char(p1);
|
||||||
char c = e->buffer()->character(e->insert_position());
|
e->buffer()->select(p1, p2);
|
||||||
if (c & 0x80 && c & 0x40) {
|
|
||||||
l = fl_utf8len(c);
|
|
||||||
}
|
|
||||||
e->buffer()->select(e->insert_position(), e->insert_position()+l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kill_selection(e);
|
kill_selection(e);
|
||||||
|
@ -497,11 +496,15 @@ int Fl_Text_Editor_mod::kf_paste(int, Fl_Text_Editor_mod* e) {
|
||||||
/** Selects all text in the current buffer.*/
|
/** Selects all text in the current buffer.*/
|
||||||
int Fl_Text_Editor_mod::kf_select_all(int, Fl_Text_Editor_mod* e) {
|
int Fl_Text_Editor_mod::kf_select_all(int, Fl_Text_Editor_mod* e) {
|
||||||
e->buffer()->select(0, e->buffer()->length());
|
e->buffer()->select(0, e->buffer()->length());
|
||||||
|
const char *copy = e->buffer()->selection_text();
|
||||||
|
if (*copy) Fl::copy(copy, strlen(copy), 0);
|
||||||
|
free((void*)copy);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/** Undo last edit in the current buffer. Also deselect previous selection. */
|
/** Undo last edit in the current buffer. Also deselect previous selection. */
|
||||||
int Fl_Text_Editor_mod::kf_undo(int , Fl_Text_Editor_mod* e) {
|
int Fl_Text_Editor_mod::kf_undo(int , Fl_Text_Editor_mod* e) {
|
||||||
e->buffer()->unselect();
|
e->buffer()->unselect();
|
||||||
|
Fl::copy("", 0, 0);
|
||||||
int crsr;
|
int crsr;
|
||||||
int ret = e->buffer()->undo(&crsr);
|
int ret = e->buffer()->undo(&crsr);
|
||||||
e->insert_position(crsr);
|
e->insert_position(crsr);
|
||||||
|
@ -519,7 +522,11 @@ int Fl_Text_Editor_mod::handle_key() {
|
||||||
// bytes to delete and a string to insert:
|
// bytes to delete and a string to insert:
|
||||||
int del = 0;
|
int del = 0;
|
||||||
if (Fl::compose(del)) {
|
if (Fl::compose(del)) {
|
||||||
if (del) buffer()->select(insert_position()-del, insert_position());
|
if (del) {
|
||||||
|
int dp = insert_position(), di = del;
|
||||||
|
while (di--) dp = buffer()->prev_char_clipped(dp);
|
||||||
|
buffer()->select(dp, insert_position());
|
||||||
|
}
|
||||||
kill_selection(this);
|
kill_selection(this);
|
||||||
if (Fl::event_length()) {
|
if (Fl::event_length()) {
|
||||||
if (insert_mode()) insert(Fl::event_text());
|
if (insert_mode()) insert(Fl::event_text());
|
||||||
|
@ -549,6 +556,8 @@ void Fl_Text_Editor_mod::maybe_do_callback() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Fl_Text_Editor_mod::handle(int event) {
|
int Fl_Text_Editor_mod::handle(int event) {
|
||||||
|
static int dndCursorPos;
|
||||||
|
|
||||||
if (!buffer()) return 0;
|
if (!buffer()) return 0;
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
@ -593,7 +602,12 @@ int Fl_Text_Editor_mod::handle(int event) {
|
||||||
if (Fl::event_button() == 2) {
|
if (Fl::event_button() == 2) {
|
||||||
// don't let the text_display see this event
|
// don't let the text_display see this event
|
||||||
if (Fl_Group::handle(event)) return 1;
|
if (Fl_Group::handle(event)) return 1;
|
||||||
dragType = -1;
|
dragType = DRAG_NONE;
|
||||||
|
if(buffer()->selected()) {
|
||||||
|
buffer()->unselect();
|
||||||
|
}
|
||||||
|
int pos = xy_to_position(Fl::event_x(), Fl::event_y(), CURSOR_POS);
|
||||||
|
insert_position(pos);
|
||||||
Fl::paste(*this, 0);
|
Fl::paste(*this, 0);
|
||||||
Fl::focus(this);
|
Fl::focus(this);
|
||||||
set_changed();
|
set_changed();
|
||||||
|
@ -610,11 +624,29 @@ int Fl_Text_Editor_mod::handle(int event) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Handle drag'n'drop attempt by the user. This is a simplified
|
||||||
|
// implementation which allows dnd operations onto the scroll bars.
|
||||||
|
case FL_DND_ENTER: // save the current cursor position
|
||||||
|
if (Fl::visible_focus() && handle(FL_FOCUS))
|
||||||
|
Fl::focus(this);
|
||||||
|
show_cursor(mCursorOn);
|
||||||
|
dndCursorPos = insert_position();
|
||||||
|
/* fall through */
|
||||||
|
case FL_DND_DRAG: // show a temporary insertion cursor
|
||||||
|
insert_position(xy_to_position(Fl::event_x(), Fl::event_y(), CURSOR_POS));
|
||||||
|
return 1;
|
||||||
|
case FL_DND_LEAVE: // restore original cursor
|
||||||
|
insert_position(dndCursorPos);
|
||||||
|
return 1;
|
||||||
|
case FL_DND_RELEASE: // keep insertion cursor and wait for the FL_PASTE event
|
||||||
|
buffer()->unselect(); // FL_PASTE must not destroy current selection!
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Fl_Text_Display_mod::handle(event);
|
return Fl_Text_Display_mod::handle(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: Fl_Text_Editor.cxx 7462 2010-04-06 23:00:56Z matt $".
|
// End of "$Id: Fl_Text_Editor_mod.cxx 8034 2010-12-15 12:21:55Z AlbrechtS $".
|
||||||
//
|
//
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
#include <FL/Fl_Window.H>
|
#include <FL/Fl_Window.H>
|
||||||
|
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#define FLTK13
|
||||||
|
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3
|
||||||
|
#undef FLTK13
|
||||||
|
#endif
|
||||||
|
|
||||||
// Drag the edges that were initially at oldx,oldy to newx,newy:
|
// Drag the edges that were initially at oldx,oldy to newx,newy:
|
||||||
// pass -1 as oldx or oldy to disable drag in that direction:
|
// pass -1 as oldx or oldy to disable drag in that direction:
|
||||||
|
@ -37,7 +43,11 @@
|
||||||
int Panel::orgx()
|
int Panel::orgx()
|
||||||
{
|
{
|
||||||
int oldx = w();
|
int oldx = w();
|
||||||
|
#ifdef FLTK13
|
||||||
|
int *p = sizes() + 8;
|
||||||
|
#else
|
||||||
short* p = sizes()+8;
|
short* p = sizes()+8;
|
||||||
|
#endif
|
||||||
for (int i=children(); i--; p += 4)
|
for (int i=children(); i--; p += 4)
|
||||||
if (p[1] < oldx) oldx = p[1];
|
if (p[1] < oldx) oldx = p[1];
|
||||||
return oldx;
|
return oldx;
|
||||||
|
@ -46,7 +56,11 @@ int Panel::orgx()
|
||||||
int Panel::orgy()
|
int Panel::orgy()
|
||||||
{
|
{
|
||||||
int oldy = h();
|
int oldy = h();
|
||||||
|
#ifdef FLTK13
|
||||||
|
int *p = sizes() + 8;
|
||||||
|
#else
|
||||||
short* p = sizes()+8;
|
short* p = sizes()+8;
|
||||||
|
#endif
|
||||||
for (int i=children(); i--; p += 4)
|
for (int i=children(); i--; p += 4)
|
||||||
if (p[3] < oldy) oldy = p[3];
|
if (p[3] < oldy) oldy = p[3];
|
||||||
return oldy;
|
return oldy;
|
||||||
|
@ -55,7 +69,11 @@ int Panel::orgy()
|
||||||
void Panel::position(int oix, int oiy, int newx, int newy) {
|
void Panel::position(int oix, int oiy, int newx, int newy) {
|
||||||
//printf("oix %3d, oiy %3d, nux %3d, nuy %3d\n", oix, oiy, newx, newy);
|
//printf("oix %3d, oiy %3d, nux %3d, nuy %3d\n", oix, oiy, newx, newy);
|
||||||
Fl_Widget* const* a = array();
|
Fl_Widget* const* a = array();
|
||||||
|
#ifdef FLTK13
|
||||||
|
int *p = sizes();
|
||||||
|
#else
|
||||||
short* p = sizes();
|
short* p = sizes();
|
||||||
|
#endif
|
||||||
//printf("p0 %3d, p1 %3d, p2 %3d, p3 %3d\n", p[0], p[1], p[2], p[3]);
|
//printf("p0 %3d, p1 %3d, p2 %3d, p3 %3d\n", p[0], p[1], p[2], p[3]);
|
||||||
//printf("p4 %3d, p5 %3d, p6 %3d, p7 %3d\n", p[0], p[1], p[2], p[3]);
|
//printf("p4 %3d, p5 %3d, p6 %3d, p7 %3d\n", p[0], p[1], p[2], p[3]);
|
||||||
p += 8; // skip group & resizable's saved size
|
p += 8; // skip group & resizable's saved size
|
||||||
|
@ -90,7 +108,11 @@ void Panel::position(int oix, int oiy, int newx, int newy) {
|
||||||
// move the lower-right corner (sort of):
|
// move the lower-right corner (sort of):
|
||||||
void Panel::resize(int X,int Y,int W,int H) {
|
void Panel::resize(int X,int Y,int W,int H) {
|
||||||
// remember how much to move the child widgets:
|
// remember how much to move the child widgets:
|
||||||
|
#ifdef FLTK13
|
||||||
|
int *p = sizes();
|
||||||
|
#else
|
||||||
short* p = sizes();
|
short* p = sizes();
|
||||||
|
#endif
|
||||||
int OX = x();
|
int OX = x();
|
||||||
int OY = y();
|
int OY = y();
|
||||||
int OW = w();
|
int OW = w();
|
||||||
|
@ -191,8 +213,13 @@ int Panel::handle(int event) {
|
||||||
int oldx = 0;
|
int oldx = 0;
|
||||||
int oldy = 0;
|
int oldy = 0;
|
||||||
Fl_Widget*const* a = array();
|
Fl_Widget*const* a = array();
|
||||||
|
#ifdef FLTK13
|
||||||
|
int *q = sizes();
|
||||||
|
int *p = q + 8;
|
||||||
|
#else
|
||||||
short* q = sizes();
|
short* q = sizes();
|
||||||
short* p = q+8;
|
short* p = q + 8;
|
||||||
|
#endif
|
||||||
for (int i=children(); i--; p += 4) {
|
for (int i=children(); i--; p += 4) {
|
||||||
Fl_Widget* o = *a++;
|
Fl_Widget* o = *a++;
|
||||||
if (o == resizable()) continue;
|
if (o == resizable()) continue;
|
||||||
|
@ -227,7 +254,9 @@ int Panel::handle(int event) {
|
||||||
|
|
||||||
case FL_DRAG:
|
case FL_DRAG:
|
||||||
// This is necessary if CONSOLIDATE_MOTION in Fl_x.cxx is turned off:
|
// This is necessary if CONSOLIDATE_MOTION in Fl_x.cxx is turned off:
|
||||||
// if (damage()) return 1; // don't fall behind
|
#ifdef FLTK13
|
||||||
|
if (damage()) return 1; // don't fall behind
|
||||||
|
#endif
|
||||||
case FL_RELEASE: {
|
case FL_RELEASE: {
|
||||||
if (!sdrag) return 0; // should not happen
|
if (!sdrag) return 0; // should not happen
|
||||||
Fl_Widget* r = resizable(); if (!r) r = this;
|
Fl_Widget* r = resizable(); if (!r) r = this;
|
||||||
|
|
Ładowanie…
Reference in New Issue