Skip to content

Commit

Permalink
Merge branch 'release-1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Jan 5, 2015
2 parents 8c32d4c + 45d2144 commit 592a4b7
Show file tree
Hide file tree
Showing 9 changed files with 531 additions and 142 deletions.
30 changes: 30 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
2015-01-05 Hayaki Saito <user@zuse.jp>

* MTParser.m: Reset DECELR/DECEFR/DECSLE state with RIS sequence

* MTParser.m: Reset filter rectangle with DECELR sequence

* MTParser.m, MTShell.m, MTView.m: Implement DEC Locator filter rectangle
feature

* MTParser.m, MTShell.h, MTShell.m: Handle DECEFR

* MTParser.m, MTView.m: Implement DEC Locator one-shot mode event

* MTParser.m, MTView.m: Fix wrong DECSLE behavior

* MTShell.m: Fix a fixed size leak when initializing the tcap map

* MTShell.h, MTShell.m, MTView.h, MTView.m: Filter extra motion events
(Motion events are reported only if the mouse pointer has moved to a
different character cell.)

2015-01-04 Hayaki Saito <user@zuse.jp>

* MTParser.m, MTShell.h, MTShell.m, MTView.m, Mouse.h: Implement DECRQLP

* MTParser.m: Fix a state transition bug around CSI intermediate bytes
parsing

* MTParser.m, MTShell.h, MTShell.m, Mouse.h: Implement DECSLE

* MTParser.m, MTShell.h, MTShell.m, Mouse.h: Implement DECELR

* MTParser.m: Make sure to redraw the view after the palette state is changed

* MTParser.m, MTShell.h, MTShell.m: Parse X11 color names with a lookup table
Expand Down
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>plus-1.0a5</string>
<string>plus-1.0a6</string>
<key>NSPrincipalClass</key>
<string>MouseTerm</string>
<key>SIMBLTargetApplications</key>
Expand Down
140 changes: 140 additions & 0 deletions MTParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ static void handle_ris(struct parse_context *ppc, MTShell *shell)
[shell MouseTerm_setMouseMode: NO_MODE];
[shell MouseTerm_setFocusMode: NO];
[shell MouseTerm_setMouseProtocol: NORMAL_PROTOCOL];
[shell MouseTerm_setCoordinateType: CELL_COORDINATE];
[shell MouseTerm_setEventFilter: REQUEST_EVENT];
[shell MouseTerm_setFilterRectangle: nil];
[ppc->buffer release];
ppc->buffer = nil;
}
Expand Down Expand Up @@ -668,8 +671,29 @@ static void esc_dispatch(struct parse_context *ppc, char *p, MTShell *shell)
}
}

static void get_current_position(MTShell *shell, int *x, int *y)
{
TTView *view = (TTView *)[[[shell controller] activePane] view];
NSWindow *window = [view window];
NSPoint location = [view convertPoint: [window mouseLocationOutsideOfEventStream] toView: nil];
NSRect frame = [view frame];
*x = (int)location.x;
*y = (int)(frame.size.height - location.y);
if (*x < 0) *x = 0;
if (*y < 0) *y = 0;
if (*x >= frame.size.width) *x = frame.size.width - 1;
if (*y >= frame.size.height) *y = frame.size.height - 1;
if ([shell MouseTerm_getCoordinateType] == CELL_COORDINATE) {
CGSize size = [view cellSize];
*x = (int)round(*x / (double)size.width + 1.0);
*y = (int)round(*y / (double)size.height + 0.5);
}
}

static void csi_dispatch(struct parse_context *ppc, char *p, MTShell *shell)
{
int i;

switch (ppc->action) {
#if 0
case 'c':
Expand All @@ -689,6 +713,121 @@ static void csi_dispatch(struct parse_context *ppc, char *p, MTShell *shell)
case ('?' << 8) | 'l':
disable_extended_mode(ppc, shell);
break;
case ('\'' << 8) | 'w': /* DECEFR */
{
int x = 0;
int y = 0;
get_current_position(shell, &x, &y);
if (ppc->params_index < 1 || ppc->params[0] == 0)
ppc->params[0] = y;
if (ppc->params_index < 2 || ppc->params[1] == 0)
ppc->params[1] = x;
if (ppc->params_index < 3 || ppc->params[2] == 0)
ppc->params[2] = y;
if (ppc->params_index < 4 || ppc->params[3] == 0)
ppc->params[3] = x;
[shell MouseTerm_setFilterRectangle: [NSValue value:ppc->params
withObjCType:@encode(int[4])]];
}
break;
case ('\'' << 8) | 'z': /* DECELR */
if (ppc->params_index < 1)
ppc->params[0] = 0;
if (ppc->params_index < 2)
ppc->params[1] = 0;
switch (ppc->params[0]) {
case 1:
[shell MouseTerm_setMouseMode: DEC_LOCATOR_MODE];
break;
case 2:
[shell MouseTerm_setMouseMode: DEC_LOCATOR_ONESHOT_MODE];
break;
case 0:
default:
[shell MouseTerm_setMouseMode: NO_MODE];
break;
}
switch (ppc->params[1]) {
case 1:
[shell MouseTerm_setCoordinateType: PIXEL_COORDINATE];
break;
case 2:
case 0:
default:
[shell MouseTerm_setCoordinateType: CELL_COORDINATE];
break;
}
[shell MouseTerm_setFilterRectangle: nil];
break;
case ('\'' << 8) | '{': /* DECSLE */
for (i = 0; i < ppc->params_index; ++i) {
switch (ppc->params[i]) {
case 1:
[shell MouseTerm_setEventFilter: [shell MouseTerm_getEventFilter] | BUTTONDOWN_EVENT];
break;
case 2:
[shell MouseTerm_setEventFilter: [shell MouseTerm_getEventFilter] & ~BUTTONDOWN_EVENT];
break;
case 3:
[shell MouseTerm_setEventFilter: [shell MouseTerm_getEventFilter] | BUTTONUP_EVENT];
break;
case 4:
[shell MouseTerm_setEventFilter: [shell MouseTerm_getEventFilter] & ~BUTTONUP_EVENT];
break;
case 0:
default:
[shell MouseTerm_setEventFilter: REQUEST_EVENT];
break;
}
}
break;
case ('\'' << 8) | '|': /* DECRQLP */
{
TTView *view = (TTView *)[[[shell controller] activePane] view];
NSWindow *window = [view window];
NSPoint location = [view convertPoint: [window mouseLocationOutsideOfEventStream] toView: nil];
//Position pos = [view displayPositionForPoint: viewloc];
NSString *response = @"\033[0&w";
switch ([shell MouseTerm_getMouseMode]) {
case DEC_LOCATOR_ONESHOT_MODE:
[shell MouseTerm_setMouseMode: NO_MODE];
// pass through
case DEC_LOCATOR_MODE:
if (CGRectContainsPoint([view frame], location)) {
int pixelx = (int)location.x;
int pixely = (int)([view frame].size.height - location.y);
int cellx;
int celly;
CGSize size;
int button = 0;
if ([shell MouseTerm_getMouseState] & 1 << MOUSE_BUTTON1)
button |= 4;
if ([shell MouseTerm_getMouseState] & 1 << MOUSE_BUTTON3)
button |= 2;
if ([shell MouseTerm_getMouseState] & 1 << MOUSE_BUTTON2)
button |= 1;
switch ([shell MouseTerm_getCoordinateType]) {
case PIXEL_COORDINATE:
response = [NSString stringWithFormat: @"\033[1;%d;%d;%d;%d&w", button, pixely, pixelx, 0];
break;
case CELL_COORDINATE:
size = [view cellSize];
cellx = (int)round(pixelx / (double)size.width + 1.0);
celly = (int)round(pixely / (double)size.height + 0.5);
response = [NSString stringWithFormat: @"\033[1;%d;%d;%d;%d&w", button, celly, cellx, 0];
break;
default:
break;
}
}
break;
default:
break;
}
[(TTShell*) shell writeData: [NSData dataWithBytes: [response UTF8String]
length: response.length]];
}
break;
case 't':
if (ppc->params_index > 0) {
switch (ppc->params[0]) {
Expand Down Expand Up @@ -901,6 +1040,7 @@ int MTParser_execute(char* data, int len, id obj)
case 0x1c ... 0x1f:
break;
case 0x20 ... 0x2f:
push(ppc);
collect(ppc, p);
ppc->state = PS_CSI_INTERMEDIATE;
break;
Expand Down
17 changes: 15 additions & 2 deletions MTShell.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <Cocoa/Cocoa.h>
#import "Terminal.h"

enum parse_state {
PS_GROUND = 0,
Expand Down Expand Up @@ -50,6 +51,15 @@ struct parse_context {
- (void) MouseTerm_setMouseProtocol: (int) mouseProtocol;
- (int) MouseTerm_getMouseProtocol;

- (void) MouseTerm_setCoordinateType: (int) coordinateType;
- (int) MouseTerm_getCoordinateType;

- (void) MouseTerm_setEventFilter: (int) eventFilter;
- (int) MouseTerm_getEventFilter;

- (void) MouseTerm_setFilterRectangle: (NSValue *) filterRectangle;
- (NSValue *) MouseTerm_getFilterRectangle;

- (void) MouseTerm_setAppCursorMode: (BOOL) appCursorMode;
- (BOOL) MouseTerm_getAppCursorMode;

Expand All @@ -59,8 +69,8 @@ struct parse_context {
- (void) MouseTerm_pushTabTitle;
- (void) MouseTerm_popTabTitle;

- (void) MouseTerm_setIsMouseDown: (BOOL) isMouseDown;
- (BOOL) MouseTerm_getIsMouseDown;
- (void) MouseTerm_setMouseState: (int) state;
- (int) MouseTerm_getMouseState;

- (BOOL) MouseTerm_writeToPasteBoard: (NSString*) stringToWrite;
- (NSString*) MouseTerm_readFromPasteBoard;
Expand All @@ -73,4 +83,7 @@ struct parse_context {
- (NSMutableDictionary*) MouseTerm_getColorNameMap;
- (struct parse_context*) MouseTerm_getParseContext;

- (void) MouseTerm_cachePosition: (Position*) pos;
- (BOOL) MouseTerm_positionIsChanged: (Position*) pos;

@end
Loading

0 comments on commit 592a4b7

Please sign in to comment.