mirror of https://github.com/fltk/fltk
Mac OS text input: removed the Fl::marked_text_length() function that's not necessary.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9816 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
b22744aac0
commit
914e7f9b09
3
FL/Fl.H
3
FL/Fl.H
|
@ -142,10 +142,9 @@ public: // should be private!
|
|||
static Fl_Widget* selection_owner_;
|
||||
static Fl_Window* modal_;
|
||||
static Fl_Window* grab_;
|
||||
static int compose_state;
|
||||
static int compose_state; // used for dead keys (WIN32) or marked text (MacOS)
|
||||
static void call_screen_init(); // recompute screen number and dimensions
|
||||
#ifdef __APPLE__
|
||||
static int marked_text_length(void); // returns length of marked text
|
||||
static void reset_marked_text(); // resets marked text
|
||||
static void insertion_point_location(int x, int y, int height); // sets window coordinates & height of insertion point
|
||||
#endif
|
||||
|
|
|
@ -359,8 +359,8 @@ int Fl_Input::handle_key() {
|
|||
Fl::event_text(), Fl::event_length());
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
if (Fl::marked_text_length()) {
|
||||
this->mark( this->position() - Fl::marked_text_length() );
|
||||
if (Fl::compose_state) {
|
||||
this->mark( this->position() - Fl::compose_state );
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
|
@ -592,7 +592,7 @@ int Fl_Input::handle(int event) {
|
|||
switch (event) {
|
||||
#ifdef __APPLE__
|
||||
case FL_UNFOCUS:
|
||||
if (Fl::marked_text_length()) {
|
||||
if (Fl::compose_state) {
|
||||
this->mark( this->position() );
|
||||
Fl::reset_marked_text();
|
||||
}
|
||||
|
@ -818,7 +818,7 @@ Fl_Secret_Input::Fl_Secret_Input(int X,int Y,int W,int H,const char *l)
|
|||
int Fl_Secret_Input::handle(int event) {
|
||||
int retval = Fl_Input::handle(event);
|
||||
#ifdef __APPLE__
|
||||
if (event == FL_KEYBOARD && Fl::marked_text_length()) {
|
||||
if (event == FL_KEYBOARD && Fl::compose_state) {
|
||||
this->mark( this->position() ); // don't underline marked text
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -339,8 +339,8 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
|
|||
int offset2;
|
||||
if (pp <= e) x2 = xpos + (float)expandpos(p, pp, buf, &offset2);
|
||||
else offset2 = (int) strlen(buf);
|
||||
#ifdef __APPLE__ // Mac OS: underline marked ( = selected + Fl::marked_text_length() != 0) text
|
||||
if (Fl::marked_text_length()) {
|
||||
#ifdef __APPLE__ // Mac OS: underline marked ( = selected + Fl::compose_state != 0) text
|
||||
if (Fl::compose_state) {
|
||||
fl_color(textcolor());
|
||||
}
|
||||
else
|
||||
|
@ -351,8 +351,8 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
|
|||
fl_color(fl_contrast(textcolor(), selection_color()));
|
||||
}
|
||||
fl_draw(buf+offset1, offset2-offset1, x1, (float)(Y+ypos+desc));
|
||||
#ifdef __APPLE__ // Mac OS: underline marked ( = selected + Fl::marked_text_length() != 0) text
|
||||
if (Fl::marked_text_length()) {
|
||||
#ifdef __APPLE__ // Mac OS: underline marked ( = selected + Fl::compose_state != 0) text
|
||||
if (Fl::compose_state) {
|
||||
fl_color( fl_color_average(textcolor(), color(), 0.6) );
|
||||
float width = fl_width(buf+offset1, offset2-offset1);
|
||||
fl_line(x1, Y+ypos+height-1, x1+width, Y+ypos+height-1);
|
||||
|
@ -374,7 +374,7 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
|
|||
// draw the cursor:
|
||||
if (Fl::focus() == this && (
|
||||
#ifdef __APPLE__
|
||||
Fl::marked_text_length() ||
|
||||
Fl::compose_state ||
|
||||
#endif
|
||||
selstart == selend) &&
|
||||
position() >= p-value() && position() <= e-value()) {
|
||||
|
|
|
@ -1942,7 +1942,7 @@ void Fl_Text_Display::draw_string(int style,
|
|||
if (style & PRIMARY_MASK) {
|
||||
if (Fl::focus() == (Fl_Widget*)this) {
|
||||
#ifdef __APPLE__
|
||||
if (Fl::marked_text_length()) background = color();// Mac OS: underline marked text
|
||||
if (Fl::compose_state) background = color();// Mac OS: underline marked text
|
||||
else
|
||||
#endif
|
||||
background = selection_color();
|
||||
|
@ -1978,8 +1978,8 @@ void Fl_Text_Display::draw_string(int style,
|
|||
fl_push_clip(X, Y, toX - X, mMaxsize);
|
||||
#endif
|
||||
fl_draw( string, nChars, X, Y + mMaxsize - fl_descent());
|
||||
#ifdef __APPLE__ // Mac OS: underline marked (= selected + Fl::marked_text_length() != 0) text
|
||||
if (Fl::marked_text_length() && (style & PRIMARY_MASK)) {
|
||||
#ifdef __APPLE__ // Mac OS: underline marked (= selected + Fl::compose_state != 0) text
|
||||
if (Fl::compose_state && (style & PRIMARY_MASK)) {
|
||||
fl_color( fl_color_average(foreground, background, 0.6) );
|
||||
fl_line(X, Y + mMaxsize - 1, X + fl_width(string, nChars), Y + mMaxsize - 1);
|
||||
}
|
||||
|
@ -3476,7 +3476,7 @@ void Fl_Text_Display::draw(void) {
|
|||
if (damage() & (FL_DAMAGE_ALL | FL_DAMAGE_SCROLL | FL_DAMAGE_EXPOSE)
|
||||
&& (
|
||||
#ifdef __APPLE__
|
||||
Fl::marked_text_length() ||
|
||||
Fl::compose_state ||
|
||||
#endif
|
||||
!has_selection || mCursorPos < start || mCursorPos > end) &&
|
||||
mCursorOn && Fl::focus() == (Fl_Widget*)this ) {
|
||||
|
|
|
@ -526,9 +526,9 @@ int Fl_Text_Editor::handle_key() {
|
|||
else overstrike(Fl::event_text());
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
if (Fl::marked_text_length()) {
|
||||
if (Fl::compose_state) {
|
||||
int pos = this->insert_position();
|
||||
this->buffer()->select(pos - Fl::marked_text_length(), pos);
|
||||
this->buffer()->select(pos - Fl::compose_state, pos);
|
||||
}
|
||||
#endif
|
||||
show_insert_position();
|
||||
|
@ -569,7 +569,7 @@ int Fl_Text_Editor::handle(int event) {
|
|||
case FL_UNFOCUS:
|
||||
show_cursor(mCursorOn); // redraws the cursor
|
||||
#ifdef __APPLE__
|
||||
if (buffer()->selected() && Fl::marked_text_length()) {
|
||||
if (buffer()->selected() && Fl::compose_state) {
|
||||
int pos = insert_position();
|
||||
buffer()->select(pos, pos);
|
||||
Fl::reset_marked_text();
|
||||
|
|
|
@ -2055,8 +2055,8 @@ static void cocoaKeyboardHandler(NSEvent *theEvent)
|
|||
} else {
|
||||
received = (NSString*)aString;
|
||||
}
|
||||
/*NSLog(@"insertText=%@ l=%d Fl::marked_text_length()=%d range=%d,%d",
|
||||
received,strlen([received UTF8String]),Fl::marked_text_length(),replacementRange.location,replacementRange.length);*/
|
||||
/*NSLog(@"insertText=%@ l=%d Fl::compose_state=%d range=%d,%d",
|
||||
received,strlen([received UTF8String]),Fl::compose_state,replacementRange.location,replacementRange.length);*/
|
||||
fl_lock_function();
|
||||
Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
|
||||
while (replacementRange.length--) { // delete replacementRange.length characters before insertion point
|
||||
|
@ -2075,7 +2075,7 @@ static void cocoaKeyboardHandler(NSEvent *theEvent)
|
|||
// We can get called outside of key events (e.g., from the character palette, from CJK text input).
|
||||
// Transform character palette actions to FL_PASTE events.
|
||||
Fl_X::next_marked_length = 0;
|
||||
int flevent = (in_key_event || Fl::marked_text_length()) ? FL_KEYBOARD : FL_PASTE;
|
||||
int flevent = (in_key_event || Fl::compose_state) ? FL_KEYBOARD : FL_PASTE;
|
||||
if (!in_key_event) Fl::handle( flevent, target);
|
||||
else need_handle = YES;
|
||||
selectedRange = NSMakeRange(100, 0); // 100 is an arbitrary value
|
||||
|
@ -2098,8 +2098,8 @@ static void cocoaKeyboardHandler(NSEvent *theEvent)
|
|||
received = (NSString*)aString;
|
||||
}
|
||||
fl_lock_function();
|
||||
/*NSLog(@"setMarkedText:%@ l=%d newSelection=%d,%d Fl::marked_text_length()=%d replacement=%d,%d",
|
||||
received, strlen([received UTF8String]), newSelection.location, newSelection.length, Fl::marked_text_length(),
|
||||
/*NSLog(@"setMarkedText:%@ l=%d newSelection=%d,%d Fl::compose_state=%d replacement=%d,%d",
|
||||
received, strlen([received UTF8String]), newSelection.location, newSelection.length, Fl::compose_state,
|
||||
replacementRange.location, replacementRange.length);*/
|
||||
Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
|
||||
while (replacementRange.length--) { // delete replacementRange.length characters before insertion point
|
||||
|
@ -2137,13 +2137,13 @@ static void cocoaKeyboardHandler(NSEvent *theEvent)
|
|||
}
|
||||
|
||||
- (NSRange)markedRange {
|
||||
//NSLog(@"markedRange=%d %d", Fl::marked_text_length() > 0?0:NSNotFound, Fl::marked_text_length());
|
||||
return NSMakeRange(Fl::marked_text_length() > 0?0:NSNotFound, Fl::marked_text_length());
|
||||
//NSLog(@"markedRange=%d %d", Fl::compose_state > 0?0:NSNotFound, Fl::compose_state);
|
||||
return NSMakeRange(Fl::compose_state > 0?0:NSNotFound, Fl::compose_state);
|
||||
}
|
||||
|
||||
- (BOOL)hasMarkedText {
|
||||
//NSLog(@"hasMarkedText %s", Fl::marked_text_length() > 0?"YES":"NO");
|
||||
return (Fl::marked_text_length() > 0);
|
||||
//NSLog(@"hasMarkedText %s", Fl::compose_state > 0?"YES":"NO");
|
||||
return (Fl::compose_state > 0);
|
||||
}
|
||||
|
||||
- (NSAttributedString *)attributedSubstringFromRange:(NSRange)aRange {
|
||||
|
|
|
@ -54,8 +54,8 @@ extern XIC fl_xim_ic;
|
|||
temporary text replaced by other text during the input process. This occurs,
|
||||
e.g., when using dead keys or when entering CJK characters.
|
||||
Text editing widgets should preferentially signal
|
||||
marked text, usually underlining it. Widgets can call
|
||||
<tt>int Fl::marked_text_length()</tt> <i>after</i> having called Fl::compose(int&)
|
||||
marked text, usually underlining it. Widgets can use
|
||||
<tt>int Fl::compose_state</tt> <i>after</i> having called Fl::compose(int&)
|
||||
to obtain the length in bytes of marked text that always finishes at the
|
||||
current insertion point. It's the widget's task to underline marked text.
|
||||
Widgets should also call <tt>void Fl::reset_marked_text()</tt> when processing FL_UNFOCUS
|
||||
|
@ -105,10 +105,6 @@ unsigned char ascii = (unsigned char)e_text[0];
|
|||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
int Fl::marked_text_length() {
|
||||
return (Fl::compose_state ? Fl::compose_state : Fl_X::next_marked_length);
|
||||
}
|
||||
|
||||
static int insertion_point_x = 0;
|
||||
static int insertion_point_y = 0;
|
||||
static int insertion_point_height = 0;
|
||||
|
|
Loading…
Reference in New Issue