Mercurial > 510Connectbot
comparison src/org/tn5250j/framework/tn5250/ScreenPlanes.java @ 6:1b9e27659ef7 tn5250
adding tn5250 files
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 22 May 2014 13:10:44 -0700 |
parents | e8d2a24e85c6 |
children | bf01d1eec5c6 |
comparison
equal
deleted
inserted
replaced
5:cbdff98c45ea | 6:1b9e27659ef7 |
---|---|
27 | 27 |
28 import static org.tn5250j.TN5250jConstants.*; | 28 import static org.tn5250j.TN5250jConstants.*; |
29 | 29 |
30 import java.util.Properties; | 30 import java.util.Properties; |
31 | 31 |
32 import org.tn5250j.ExternalProgramConfig; | |
33 | |
34 public class ScreenPlanes { | 32 public class ScreenPlanes { |
35 | 33 |
36 private final Screen5250 scr; | 34 private final Screen5250 scr; |
37 private int screenSize; | 35 private int screenSize; |
38 private int numRows; | 36 private int numRows; |
756 } | 754 } |
757 | 755 |
758 return numBytes; | 756 return numBytes; |
759 } | 757 } |
760 | 758 |
761 protected boolean checkHotSpots () { | |
762 | |
763 Screen5250 s = scr; | |
764 int lenScreen = scr.getScreenLength(); | |
765 boolean hs = false; | |
766 boolean retHS = false; | |
767 StringBuffer hsMore = s.getHSMore(); | |
768 StringBuffer hsBottom = s.getHSBottom(); | |
769 | |
770 for (int x = 0; x < lenScreen; x++) { | |
771 | |
772 hs =false; | |
773 if (s.isInField(x,false)) | |
774 continue; | |
775 | |
776 // First check for PF keys | |
777 if (x > 0 && screen[x] == 'F') { | |
778 if (screen[x + 1] >= '0' && | |
779 screen[x + 1] <= '9' && | |
780 screen[x - 1] <= ' ' && | |
781 (screenExtended[x] & EXTENDED_5250_NON_DSP) == 0) { | |
782 | |
783 if (screen[x + 2] >= '0' && | |
784 screen[x + 2] <= '9' && | |
785 (screen[x + 3] == '=' || | |
786 screen[x + 3] == '-' || | |
787 screen[x + 3] == '/') ) | |
788 hs = true; | |
789 else | |
790 if ( screen[x + 2] == '=' || | |
791 screen[x + 3] == '-' || | |
792 screen[x + 3] == '/') | |
793 hs = true; | |
794 | |
795 if (hs) { | |
796 screenGUI[x] = BUTTON_LEFT; | |
797 | |
798 int ns = 0; | |
799 int row = x / numCols; | |
800 while (ns < 2 && ++x / numCols == row) { | |
801 if (screen[x] <= ' ') | |
802 ns++; | |
803 else | |
804 ns = 0; | |
805 if (ns <2) | |
806 screenGUI[x] = BUTTON_MIDDLE; | |
807 | |
808 } | |
809 | |
810 // now lets go back and take out gui's that do not belong | |
811 while (screen[--x] <= ' ') { | |
812 screenGUI[x] = NO_GUI; | |
813 } | |
814 screenGUI[x] = BUTTON_RIGHT; | |
815 | |
816 } | |
817 } | |
818 } | |
819 | |
820 // now lets check for menus | |
821 if (!hs && x > 0 && x < lenScreen - 2 && | |
822 screen[x] == '.' && | |
823 screenGUI[x] == NO_GUI && | |
824 (screenExtended[x] & EXTENDED_5250_UNDERLINE) == 0 && | |
825 (screenExtended[x] & EXTENDED_5250_NON_DSP) == 0 | |
826 ) { | |
827 | |
828 int os = 0; | |
829 if ((os = isOption(screen,x,lenScreen,2,3,'.') )> 0) { | |
830 hs = true; | |
831 | |
832 int stop = x; | |
833 int ns = 0; | |
834 int row = stop / numCols; | |
835 | |
836 while (++stop / numCols == row && | |
837 (screen[stop] >= ' ' || | |
838 screen[stop] == 0x0) ) { | |
839 | |
840 if (screen[stop] <= ' ') { | |
841 ns++; | |
842 } | |
843 else | |
844 ns = 0; | |
845 | |
846 if (screen[stop] == '.') { | |
847 int io = 0; | |
848 if ((io = isOption(screen,stop,lenScreen,2,3,'.')) > 0) { | |
849 | |
850 stop = io; | |
851 break; | |
852 } | |
853 } | |
854 | |
855 if (ns > 3) | |
856 break; | |
857 } | |
858 | |
859 screenGUI[++os] = BUTTON_LEFT; | |
860 s.setDirty(os); | |
861 | |
862 while (++os < stop) { | |
863 screenGUI[os] = BUTTON_MIDDLE; | |
864 s.setDirty(os); | |
865 } | |
866 | |
867 // now lets go back and take out gui's that do not belong | |
868 while (screen[--stop] <= ' ') { | |
869 screenGUI[stop] = NO_GUI; | |
870 s.setDirty(stop); | |
871 } | |
872 screenGUI[stop] = BUTTON_RIGHT; | |
873 s.setDirty(stop); | |
874 | |
875 } | |
876 } | |
877 | |
878 // now lets check for options. | |
879 if (!hs && x > 0 && x < lenScreen - 2 && | |
880 screen[x] == '=' && | |
881 screenGUI[x] == NO_GUI && | |
882 (screenExtended[x] & EXTENDED_5250_UNDERLINE) == 0 && | |
883 (screenExtended[x] & EXTENDED_5250_NON_DSP) == 0 | |
884 ) { | |
885 | |
886 int os = 0; | |
887 if ((os = isOption(screen,x,lenScreen,2,2,'=') )> 0) { | |
888 hs = true; | |
889 | |
890 int stop = x; | |
891 int ns = 0; | |
892 int row = stop / numCols; | |
893 | |
894 while (++stop / numCols == row && | |
895 screen[stop] >= ' ') { | |
896 | |
897 if (screen[stop] == ' ') { | |
898 ns++; | |
899 } | |
900 else | |
901 ns = 0; | |
902 | |
903 if (screen[stop] == '=') { | |
904 int io = 0; | |
905 if ((io = isOption(screen,stop,lenScreen,2,2,'=')) > 0) { | |
906 | |
907 stop = io; | |
908 break; | |
909 } | |
910 } | |
911 | |
912 if (ns > 2) | |
913 break; | |
914 } | |
915 | |
916 screenGUI[++os] = BUTTON_LEFT; | |
917 s.setDirty(os); | |
918 | |
919 while (++os < stop) { | |
920 screenGUI[os] = BUTTON_MIDDLE; | |
921 s.setDirty(os); | |
922 | |
923 } | |
924 | |
925 // now lets go back and take out gui's that do not belong | |
926 while (screen[--stop] <= ' ') { | |
927 screenGUI[stop] = NO_GUI; | |
928 s.setDirty(stop); | |
929 | |
930 } | |
931 screenGUI[stop] = BUTTON_RIGHT; | |
932 s.setDirty(stop); | |
933 } | |
934 } | |
935 | |
936 // now lets check for More... . | |
937 | |
938 if (!hs && x > 2 && x < lenScreen - hsMore.length() && | |
939 screen[x] == hsMore.charAt(0) && | |
940 screen[x - 1] <= ' ' && | |
941 screen[x - 2] <= ' ' && | |
942 screenGUI[x] == NO_GUI && | |
943 (screenExtended[x] & EXTENDED_5250_NON_DSP) == 0 | |
944 ) { | |
945 | |
946 boolean mFlag = true; | |
947 int ms = hsMore.length(); | |
948 int mc = 0; | |
949 while (++mc < ms) { | |
950 if (screen[x+mc] != hsMore.charAt(mc)) { | |
951 mFlag = false; | |
952 break; | |
953 } | |
954 | |
955 } | |
956 | |
957 if (mFlag) { | |
958 hs = true; | |
959 | |
960 screenGUI[x] = BUTTON_LEFT_DN; | |
961 | |
962 while (--ms > 0) { | |
963 screenGUI[++x] = BUTTON_MIDDLE_DN; | |
964 | |
965 } | |
966 screenGUI[x] = BUTTON_RIGHT_DN; | |
967 } | |
968 } | |
969 | |
970 // now lets check for Bottom . | |
971 if (!hs && x > 2 && x < lenScreen - hsBottom.length() && | |
972 screen[x] == hsBottom.charAt(0) && | |
973 screen[x - 1] <= ' ' && | |
974 screen[x - 2] <= ' ' && | |
975 screenGUI[x] == NO_GUI && | |
976 (screenExtended[x] & EXTENDED_5250_NON_DSP) == 0 | |
977 ) { | |
978 | |
979 boolean mFlag = true; | |
980 int bs = hsBottom.length(); | |
981 int bc = 0; | |
982 while (++bc < bs) { | |
983 if (screen[x+bc] != hsBottom.charAt(bc)) { | |
984 mFlag = false; | |
985 break; | |
986 } | |
987 | |
988 } | |
989 | |
990 if (mFlag) { | |
991 hs = true; | |
992 | |
993 screenGUI[x] = BUTTON_LEFT_UP; | |
994 | |
995 while (--bs > 0) { | |
996 screenGUI[++x] = BUTTON_MIDDLE_UP; | |
997 | |
998 } | |
999 screenGUI[x] = BUTTON_RIGHT_UP; | |
1000 } | |
1001 } | |
1002 | |
1003 // Submitted by Richard Houston of RLH Consulting rhouston@rlhc.net | |
1004 // now lets check for HTTP:// or HTTPS://. | |
1005 if (!hs && x > 0 && x < lenScreen - 7 && | |
1006 Character.toLowerCase(screen[x]) == 'h' && | |
1007 screen[x - 1] <= ' ' && | |
1008 screenGUI[x] == NO_GUI && | |
1009 (screenExtended[x] & EXTENDED_5250_NON_DSP) == 0 | |
1010 ) { | |
1011 | |
1012 if (Character.toLowerCase(screen[x+1]) == 't' && | |
1013 Character.toLowerCase(screen[x+2]) == 't' && | |
1014 Character.toLowerCase(screen[x+3]) == 'p' && | |
1015 screen[x+4] == ':' && | |
1016 screen[x+5] == '/' && | |
1017 screen[x+6] == '/' ) { | |
1018 | |
1019 hs = true; | |
1020 | |
1021 screenGUI[x] = BUTTON_LEFT_EB; | |
1022 | |
1023 while (screen[++x] > ' ') { | |
1024 screenGUI[x] = BUTTON_MIDDLE_EB; | |
1025 | |
1026 } | |
1027 | |
1028 screenGUI[--x] = BUTTON_RIGHT_EB; | |
1029 } | |
1030 | |
1031 else if (Character.toLowerCase(screen[x+1]) == 't' && | |
1032 Character.toLowerCase(screen[x+2]) == 't' && | |
1033 Character.toLowerCase(screen[x+3]) == 'p' && | |
1034 Character.toLowerCase(screen[x+4]) == 's' && | |
1035 screen[x+5] == ':' && | |
1036 screen[x+6] == '/' && | |
1037 screen[x+7] == '/' ) { | |
1038 | |
1039 hs = true; | |
1040 | |
1041 screenGUI[x] = BUTTON_LEFT_EB; | |
1042 | |
1043 while (screen[++x] > ' ') { | |
1044 screenGUI[x] = BUTTON_MIDDLE_EB; | |
1045 | |
1046 } | |
1047 | |
1048 screenGUI[--x] = BUTTON_RIGHT_EB; | |
1049 } | |
1050 | |
1051 } | |
1052 // now lets check for MAILTO: . | |
1053 else if (!hs && x > 0 && x < lenScreen - 7 && | |
1054 Character.toLowerCase(screen[x]) == 'm' && | |
1055 screen[x - 1] <= ' ' && | |
1056 screenGUI[x] == NO_GUI && | |
1057 (screenExtended[x] & EXTENDED_5250_NON_DSP) == 0 | |
1058 ) { | |
1059 | |
1060 if (Character.toLowerCase(screen[x+1]) == 'a' && | |
1061 Character.toLowerCase(screen[x+2]) == 'i' && | |
1062 Character.toLowerCase(screen[x+3]) == 'l' && | |
1063 Character.toLowerCase(screen[x+4]) == 't' && | |
1064 Character.toLowerCase(screen[x+5]) == 'o' && | |
1065 screen[x+6] == ':') { | |
1066 | |
1067 hs = true; | |
1068 | |
1069 screenGUI[x] = BUTTON_LEFT_EB; | |
1070 | |
1071 while (screen[++x] > ' ') { | |
1072 screenGUI[x] = BUTTON_MIDDLE_EB; | |
1073 | |
1074 } | |
1075 screenGUI[--x] = BUTTON_RIGHT_EB; | |
1076 } | |
1077 } | |
1078 // now lets check for External Program: . | |
1079 else if (!hs && x > 0 && x < lenScreen - 7 && | |
1080 screen[x - 1] <= ' ' && | |
1081 screenGUI[x] == NO_GUI && | |
1082 (screenExtended[x] & EXTENDED_5250_NON_DSP) == 0 | |
1083 ) { | |
1084 Properties etnProps = ExternalProgramConfig.getInstance().getEtnPgmProps(); | |
1085 String count = etnProps.getProperty("etn.pgm.support.total.num"); | |
1086 if(count != null && count.length() > 0){ | |
1087 int total = Integer.parseInt(count); | |
1088 for(int i=1;i<=total;i++){ | |
1089 String program = etnProps.getProperty("etn.pgm."+i+".command.name"); | |
1090 String key=""; | |
1091 if(x + program.length() >= screen.length) break; | |
1092 for(int j=0;j<=program.length();j++){ | |
1093 key+=screen[x+j]; | |
1094 } | |
1095 if(key.toLowerCase().equals(program.toLowerCase()+":")) { | |
1096 hs = true; | |
1097 screenGUI[x] = BUTTON_LEFT_EB; | |
1098 while (screen[++x] > ' ') { | |
1099 screenGUI[x] = BUTTON_MIDDLE_EB; | |
1100 } | |
1101 screenGUI[--x] = BUTTON_RIGHT_EB; | |
1102 break; | |
1103 } | |
1104 } | |
1105 } | |
1106 } | |
1107 | |
1108 if (!retHS && hs) | |
1109 retHS = true; | |
1110 | |
1111 } | |
1112 | |
1113 return retHS; | |
1114 } | |
1115 | |
1116 private int isOption(char[] screen, | 759 private int isOption(char[] screen, |
1117 int x, | 760 int x, |
1118 int lenScreen, | 761 int lenScreen, |
1119 int numPref, | 762 int numPref, |
1120 int numSuff, | 763 int numSuff, |