-------------------------------------------------------------------------*/
| 1009 | } |
| 1010 | /*-------------------------------------------------------------------------*/ |
| 1011 | void |
| 1012 | ActivateCell(HWND hWnd, int cell) |
| 1013 | { |
| 1014 | PNHCmdWindow data; |
| 1015 | PNHCmdPadCell p_cell_data; |
| 1016 | int i; |
| 1017 | |
| 1018 | data = (PNHCmdWindow) GetWindowLong(hWnd, GWL_USERDATA); |
| 1019 | if (!data) |
| 1020 | return; |
| 1021 | p_cell_data = nhcmdlayout_cell_direct(data->layout_current, cell); |
| 1022 | |
| 1023 | /* act depending on the cell type: |
| 1024 | CAPS - change layout |
| 1025 | CTRL - modify CTRL status |
| 1026 | REG - place keyboard event on the nethack input queue |
| 1027 | */ |
| 1028 | switch (p_cell_data->type) { |
| 1029 | case NH_CELL_REG: |
| 1030 | if (data->is_ctrl) { |
| 1031 | PushNethackCommand(p_cell_data->f_char, 1); |
| 1032 | |
| 1033 | data->is_ctrl = 0; |
| 1034 | for (i = 0; i < nhcmdlayout_rows(data->layout_current) |
| 1035 | * nhcmdlayout_columns(data->layout_current); |
| 1036 | i++) { |
| 1037 | if (nhcmdlayout_cell_direct(data->layout_current, i)->type |
| 1038 | == NH_CELL_CTRL) { |
| 1039 | HighlightCell(hWnd, i, data->is_ctrl); |
| 1040 | } |
| 1041 | } |
| 1042 | } else { |
| 1043 | PushNethackCommand(p_cell_data->f_char, 0); |
| 1044 | } |
| 1045 | HighlightCell(hWnd, cell, FALSE); |
| 1046 | |
| 1047 | // select a new layout if present |
| 1048 | i = (int) p_cell_data->data; |
| 1049 | if (i == -1) { |
| 1050 | if (data->layout_save) |
| 1051 | SetCmdWindowLayout(hWnd, data->layout_save); |
| 1052 | data->layout_save = NULL; |
| 1053 | } else { |
| 1054 | if (!data->layout_save) |
| 1055 | data->layout_save = data->layout_current; |
| 1056 | SetCmdWindowLayout(hWnd, nhcmdset_get(nhcmdset_current, i)); |
| 1057 | } |
| 1058 | |
| 1059 | if (!data->is_shift) |
| 1060 | break; |
| 1061 | // else fall through and reset the shift |
| 1062 | |
| 1063 | case NH_CELL_SHIFT: |
| 1064 | data->is_shift = !data->is_shift; |
| 1065 | SetCmdWindowLayout(hWnd, (data->is_shift ^ data->is_caps) |
| 1066 | ? nhcmdset_get(nhcmdset_current, 1) |
| 1067 | : nhcmdset_get(nhcmdset_current, 0)); |
| 1068 | data->cells[cell].state = data->is_shift ? NH_CST_CHECKED : 0; |
no test coverage detected