Changeset 3922 for trunk/src/riched32
- Timestamp:
- Aug 2, 2000, 4:58:40 PM (25 years ago)
- Location:
- trunk/src/riched32
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/riched32/charlist.c
r3515 r3922 1 /* $Id: charlist.c,v 1.2 2000-08-02 14:58:40 bird Exp $ */ 1 2 /* 2 * 3 * 3 4 * Character List 4 * 5 * 5 6 * Copyright (c) 2000 by Jean-Claude Batista 6 * 7 * 7 8 */ 8 9 … … 18 19 19 20 void CHARLIST_Enqueue( CHARLIST* pCharList, char myChar ) 20 { 21 { 21 22 CHARLISTENTRY* pNewEntry = HeapAlloc(RICHED32_hHeap, 0,sizeof(CHARLISTENTRY)); 22 23 pNewEntry->pNext = NULL; 23 24 pNewEntry->myChar = myChar; 24 25 25 26 if(pCharList->pTail == NULL) 26 27 { … … 29 30 else 30 31 { 31 CHARLISTENTRY* pCurrent = pCharList->pTail; 32 CHARLISTENTRY* pCurrent = pCharList->pTail; 32 33 pCharList->pTail = pCurrent->pNext = pNewEntry; 33 34 } … … 37 38 38 39 void CHARLIST_Push( CHARLIST* pCharList, char myChar) 39 { 40 { 40 41 CHARLISTENTRY* pNewEntry = malloc(sizeof(CHARLISTENTRY)); 41 42 42 43 pNewEntry->myChar = myChar; 43 44 44 45 if(pCharList->pHead == NULL) 45 46 { … … 62 63 char myChar; 63 64 64 if(pCharList->nCount == 0) 65 if(pCharList->nCount == 0) 65 66 return 0; 66 67 67 68 pCharList->nCount--; 68 69 myChar = pCharList->pHead->myChar; 69 70 pCurrent = pCharList->pHead->pNext; 70 71 HeapFree(RICHED32_hHeap, 0,pCharList->pHead); 71 72 72 73 if(pCharList->nCount == 0) 73 74 { … … 79 80 } 80 81 81 return myChar; 82 return myChar; 82 83 } 83 84 … … 89 90 void CHARLIST_FreeList(CHARLIST* pCharList){ 90 91 while(pCharList->nCount) 91 CHARLIST_Dequeue(pCharList); 92 CHARLIST_Dequeue(pCharList); 92 93 } 93 94 … … 97 98 CHARLISTENTRY *pCurrent; 98 99 int nCount = 0; 99 100 100 101 for(pCurrent =pCharList->pHead ;pCurrent;pCurrent=pCurrent->pNext) 101 102 if(pCurrent->myChar == myChar) 102 103 nCount++; 103 104 104 105 return nCount; 105 106 } … … 107 108 int CHARLIST_toBuffer(CHARLIST* pCharList, char* pBuffer, int nBufferSize) 108 109 { 109 110 110 111 /* we add one to store a NULL caracter */ 111 if(nBufferSize < pCharList->nCount + 1) 112 if(nBufferSize < pCharList->nCount + 1) 112 113 return pCharList->nCount; 113 114 114 115 for(;pCharList->nCount;pBuffer++) 115 116 *pBuffer = CHARLIST_Dequeue(pCharList); 116 117 117 118 *pBuffer = '\0'; 118 119 -
trunk/src/riched32/reader.c
r3515 r3922 1 /* $Id: reader.c,v 1.2 2000-08-02 14:58:40 bird Exp $ */ 1 2 /* 2 3 * - Need to document error code meanings. … … 67 68 * include hard coded charsets 68 69 */ 69 70 70 71 #include "ansi_gen.h" 71 72 #include "ansi_sym.h" … … 210 211 * Get a char from the charlist. The charlist is used to store characters 211 212 * from the editstream. 212 * 213 */ 214 215 int 213 * 214 */ 215 216 int 216 217 _RTFGetChar() 217 218 { … … 267 268 RTFFree (outputName); 268 269 inputName = outputName = (char *) NULL; 269 270 270 271 /* initialize lookup table */ 271 272 LookupInit (); … … 829 830 */ 830 831 831 832 832 833 static int 833 834 GetChar () … … 953 954 /* 954 955 * Do auto-charset-file reading. 955 * will always use the ansi charset no mater what the value 956 * will always use the ansi charset no mater what the value 956 957 * of the rtfTextBuf is. 957 958 * 958 959 * TODO: add support for other charset in the future. 959 * 960 * 960 961 */ 961 962 … … 982 983 983 984 /* 984 * Convert a CaracterSetMap (caracter_name, caracter) into 985 * Convert a CaracterSetMap (caracter_name, caracter) into 985 986 * this form : array[caracter_ident] = caracter; 986 987 */ … … 997 998 return (0); /* illegal charset id */ 998 999 case rtfCSGeneral: 999 1000 1000 1001 haveGenCharSet = 1; 1001 1002 stdCodeArray = genCharCode; … … 1010 1011 } 1011 1012 break; 1012 1013 1013 1014 case rtfCSSymbol: 1014 1015 … … 1023 1024 { 1024 1025 stdCodeArray[ ansi_sym[i+1] ] = ansi_sym[i]; 1025 } 1026 } 1026 1027 break; 1027 1028 } … … 1203 1204 fp->rtfFCodePage = 0; 1204 1205 1205 while (rtfClass != rtfEOF 1206 while (rtfClass != rtfEOF 1206 1207 && !RTFCheckCM (rtfText, ';') 1207 1208 && !RTFCheckCM (rtfGroup, rtfEndGroup)) … … 1264 1265 (void) RTFGetToken (); 1265 1266 } 1266 1267 1267 1268 /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */ 1268 1269 if(RTFCheckCM (rtfGroup, rtfEndGroup)) 1269 1270 { 1270 1271 RTFUngetToken (); 1271 } 1272 } 1272 1273 *bp = '\0'; 1273 1274 fp->rtfFName = RTFStrSave (buf); … … 2736 2737 * char *outMap[rtfSC_MaxChar]; 2737 2738 * 2738 * reinit should be non-zero if outMap should be initialized 2739 * reinit should be non-zero if outMap should be initialized 2739 2740 * zero otherwise. 2740 2741 * -
trunk/src/riched32/richedit.c
r3787 r3922 1 /* $Id: richedit.c,v 1.3 2000-08-02 14:58:40 bird Exp $ */ 1 2 /* 2 3 * RichEdit32 functions 3 4 * 4 5 * This module is a simple wrap-arround the edit controls. 5 * At the point, it is good only for application who use the RICHEDIT control to 6 * At the point, it is good only for application who use the RICHEDIT control to 6 7 * display RTF text. 7 8 * 8 9 * Copyright 2000 by Jean-Claude Batista 9 * 10 */ 11 10 * 11 */ 12 12 13 #include "windows.h" 13 14 #include "winbase.h" … … 47 48 RICHED32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 48 49 { 49 50 50 51 switch (fdwReason) { 51 52 case DLL_PROCESS_ATTACH: … … 60 61 61 62 } 62 63 63 64 /* register the Rich Edit class */ 64 65 RICHED32_Register (); … … 70 71 RICHED32_dwProcessesAttached--; 71 72 72 /* unregister all common control classes */ 73 /* unregister all common control classes */ 73 74 RICHED32_Unregister (); 74 75 … … 77 78 RICHED32_hHeap = (HANDLE)NULL; 78 79 } 79 break; 80 break; 80 81 } 81 82 … … 94 95 int RTFToBuffer(char* pBuffer, int nBufferSize); 95 96 LONG newstyle = 0; 96 LONG style = 0; 97 LONG style = 0; 97 98 98 99 static HWND hwndEdit; 99 100 static char* rtfBuffer; 100 101 int rtfBufferSize; 101 102 102 103 switch (uMsg) 103 104 { 104 105 case WM_CREATE : 106 105 106 case WM_CREATE : 107 107 108 /* remove SCROLLBARS from the current window style */ 108 109 newstyle = style = ((LPCREATESTRUCTA) lParam)->style; … … 113 114 114 115 #ifdef __WIN32OS2__ 115 style |= WS_CHILD; 116 style |= WS_CHILD; 116 117 #endif 117 118 hwndEdit = CreateWindowA ("edit", ((LPCREATESTRUCTA) lParam)->lpszName, … … 119 120 hwnd, (HMENU) ID_EDIT, 120 121 ((LPCREATESTRUCTA) lParam)->hInstance, NULL) ; 121 122 SetWindowLongA(hwnd,GWL_STYLE, newstyle); 123 return 0 ; 124 125 case WM_SETFOCUS : 122 123 SetWindowLongA(hwnd,GWL_STYLE, newstyle); 124 return 0 ; 125 126 case WM_SETFOCUS : 126 127 SetFocus (hwndEdit) ; 127 128 return 0 ; 128 129 case WM_SIZE : 129 130 case WM_SIZE : 130 131 MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ; 131 132 return 0 ; 132 133 133 134 case WM_COMMAND : 134 135 if (LOWORD (wParam) == ID_EDIT) 135 if (HIWORD (wParam) == EN_ERRSPACE || 136 if (HIWORD (wParam) == EN_ERRSPACE || 136 137 HIWORD (wParam) == EN_MAXTEXT) 137 138 … … 139 140 "ERROR", MB_OK | MB_ICONSTOP) ; 140 141 return 0 ; 141 142 case EM_STREAMIN: 143 142 143 case EM_STREAMIN: 144 144 145 /* setup the RTF parser */ 145 146 RTFSetEditStream(( EDITSTREAM*)lParam); 146 147 WriterInit(); 147 148 RTFInit (); 148 BeginFile(); 149 BeginFile(); 149 150 150 151 /* do the parsing */ 151 152 RTFRead (); 152 153 153 154 rtfBufferSize = RTFToBuffer(NULL, 0); 154 155 rtfBuffer = HeapAlloc(RICHED32_hHeap, 0,rtfBufferSize*sizeof(char)); … … 161 162 else 162 163 WARN("Not enough memory for a allocating rtfBuffer\n"); 163 164 return 0; 164 165 return 0; 165 166 } 166 167 /*return SendMessageA( hwndEdit,uMsg,wParam,lParam);*/ … … 188 189 { 189 190 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) { 190 191 191 192 return E_INVALIDARG; 192 193 } … … 203 204 * DESCRIPTION: 204 205 * Registers the window class. 205 * 206 * 206 207 * PARAMETER(S): 207 208 * None … … 212 213 VOID RICHED32_Register(void) 213 214 { 214 WNDCLASSA wndClass; 215 WNDCLASSA wndClass; 215 216 216 217 ZeroMemory(&wndClass, sizeof(WNDCLASSA)); … … 229 230 * DESCRIPTION: 230 231 * Unregisters the window class. 231 * 232 * 232 233 * PARAMETER(S): 233 234 * None -
trunk/src/riched32/text-writer.c
r3515 r3922 1 /* $Id: text-writer.c,v 1.2 2000-08-02 14:58:40 bird Exp $ */ 1 2 /* 2 3 * text-writer -- RTF-to-text translation writer code. … … 58 59 int RTFToBuffer(char* pBuffer, int nBufferSize) 59 60 { 60 61 /* check if the buffer is big enough to hold all characters */ 61 62 /* check if the buffer is big enough to hold all characters */ 62 63 /* we require one more for the '\0' */ 63 64 64 65 65 66 if(nBufferSize < charlist.nCount + 1) { 66 67 return charlist.nCount + CHARLIST_CountChar(&charlist, '\n') + 1; 67 68 } 68 69 69 70 while(charlist.nCount) 70 71 { … … 74 75 *pBuffer = '\r'; 75 76 pBuffer++; 76 *pBuffer = '\n'; 77 *pBuffer = '\n'; 77 78 } 78 79 pBuffer++; … … 80 81 *pBuffer = '\0'; 81 82 82 return 0; 83 return 0; 83 84 } 84 85 … … 243 244 void PutStdChar (int stdCode) 244 245 { 245 246 246 247 char *oStr = (char *) NULL; 247 248 char buf[rtfBufSiz]; 248 249 249 250 /* if (stdCode == rtfSC_nothing) 250 251 RTFPanic ("Unknown character code, logic error\n"); 251 */ 252 */ 252 253 oStr = outMap[stdCode]; 253 254 if (oStr == (char *) NULL) /* no output sequence in map */
Note:
See TracChangeset
for help on using the changeset viewer.