Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 15932
Collapse All | Expand All

(-)ratpoison-1.2.0.cvs.20020425/src/actions.c (+36 lines)
Lines 43-48 Link Here
43
    {"echo", 		cmd_echo, 	arg_STRING},
43
    {"echo", 		cmd_echo, 	arg_STRING},
44
    {"escape",          cmd_escape,     arg_STRING},
44
    {"escape",          cmd_escape,     arg_STRING},
45
    {"exec", 		cmd_exec, 	arg_STRING},
45
    {"exec", 		cmd_exec, 	arg_STRING},
46
    {"verbexec", 		cmd_verbexec, 	arg_STRING},
46
    {"focus",		cmd_next_frame,	arg_VOID},
47
    {"focus",		cmd_next_frame,	arg_VOID},
47
    {"focusup",		cmd_focusup,	arg_VOID},
48
    {"focusup",		cmd_focusup,	arg_VOID},
48
    {"focusdown",	cmd_focusdown,	arg_VOID},
49
    {"focusdown",	cmd_focusdown,	arg_VOID},
Lines 99-104 Link Here
99
    {"defbarborder",		cmd_defbarborder,	arg_STRING},
100
    {"defbarborder",		cmd_defbarborder,	arg_STRING},
100
    {"deftransgravity",		cmd_deftransgravity,	arg_STRING},
101
    {"deftransgravity",		cmd_deftransgravity,	arg_STRING},
101
    {"defwaitcursor",		cmd_defwaitcursor,	arg_STRING},
102
    {"defwaitcursor",		cmd_defwaitcursor,	arg_STRING},
103
    {"defwrapwinlist",		cmd_defwrapwinlist,	arg_STRING},          
104
    {"togglewrapwinlist",	cmd_togglewrapwinlist,	arg_STRING},          
102
    {"defwinfmt", 		cmd_defwinfmt, 		arg_STRING},
105
    {"defwinfmt", 		cmd_defwinfmt, 		arg_STRING},
103
    {"defwinname", 		cmd_defwinname,		arg_STRING},
106
    {"defwinname", 		cmd_defwinname,		arg_STRING},
104
    {"defwingravity",		cmd_defwingravity,	arg_STRING},
107
    {"defwingravity",		cmd_defwingravity,	arg_STRING},
Lines 967-972 Link Here
967
  return NULL;
970
  return NULL;
968
}
971
}
969
972
973
char *
974
cmd_verbexec (int interactive, void *data)
975
{
976
  char msg[100]="Running ";
977
  strncat(msg, data, 100-strlen(msg));
978
  
979
  if(data) cmd_echo(interactive, msg);
980
  return cmd_exec(interactive, data);
981
}
982
970
983
971
void
984
void
972
spawn(void *data)
985
spawn(void *data)
Lines 1953-1958 Link Here
1953
      || sscanf (data, "%d", &defaults.wait_for_key_cursor) < 1)
1966
      || sscanf (data, "%d", &defaults.wait_for_key_cursor) < 1)
1954
    {
1967
    {
1955
      message (" defwaitforkey: One argument required ");
1968
      message (" defwaitforkey: One argument required ");
1969
    }
1970
1971
  return NULL;
1972
}
1973
1974
1975
char*
1976
cmd_togglewrapwinlist()
1977
{
1978
  if(defaults.wrap_window_list) return cmd_defwrapwinlist(0,(void*)"0");
1979
  return cmd_defwrapwinlist(0,(void*)"1");
1980
}
1981
1982
char *
1983
cmd_defwrapwinlist (int interactive, void *data)
1984
{
1985
  if (data == NULL && !interactive)
1986
    return xsprintf ("%d", defaults.wrap_window_list);
1987
1988
  if (data == NULL
1989
      || sscanf (data, "%d", &defaults.wrap_window_list) < 1)
1990
    {
1991
      message (" defwrapwinlist: One argument required ");
1956
    }
1992
    }
1957
1993
1958
  return NULL;    
1994
  return NULL;    
(-)ratpoison-1.2.0.cvs.20020425/src/actions.h (+3 lines)
Lines 44-49 Link Here
44
char * cmd_meta (int interactive, void *data);
44
char * cmd_meta (int interactive, void *data);
45
char * cmd_abort (int interactive, void *data);
45
char * cmd_abort (int interactive, void *data);
46
char * cmd_exec (int interactive, void *data);
46
char * cmd_exec (int interactive, void *data);
47
char * cmd_verbexec (int interactive, void *data);
47
char * cmd_colon (int interactive, void *data);
48
char * cmd_colon (int interactive, void *data);
48
char * cmd_kill (int interactive, void *data);
49
char * cmd_kill (int interactive, void *data);
49
char * cmd_delete (int interactive, void *data);
50
char * cmd_delete (int interactive, void *data);
Lines 86-91 Link Here
86
char * cmd_defborder (int interactive, void *data);
87
char * cmd_defborder (int interactive, void *data);
87
char * cmd_definputwidth (int interactive, void *data);
88
char * cmd_definputwidth (int interactive, void *data);
88
char * cmd_defwaitcursor (int interactive, void *data);
89
char * cmd_defwaitcursor (int interactive, void *data);
90
char * cmd_defwrapwinlist (int interactive, void *data);
91
char * cmd_togglewrapwinlist ();
89
char * cmd_defwinfmt (int interactive, void *data);
92
char * cmd_defwinfmt (int interactive, void *data);
90
char * cmd_defwinname (int interactive, void *data);
93
char * cmd_defwinname (int interactive, void *data);
91
char * cmd_deffgcolor (int interactive, void *data);
94
char * cmd_deffgcolor (int interactive, void *data);
(-)ratpoison-1.2.0.cvs.20020425/src/bar.c (-6 / +236 lines)
Lines 107-113 Link Here
107
}
107
}
108
108
109
int
109
int
110
bar_y (screen_info *s)
110
bar_y (screen_info *s, int height)
111
{
111
{
112
  int y = 0;
112
  int y = 0;
113
113
Lines 121-133 Link Here
121
    case EastGravity:
121
    case EastGravity:
122
    case CenterGravity:
122
    case CenterGravity:
123
    case WestGravity:
123
    case WestGravity:
124
      y = (s->root_attr.height - (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2) 
124
      y = (s->root_attr.height - height 
125
	   - defaults.bar_border_width * 2) / 2;
125
	   - defaults.bar_border_width * 2) / 2;
126
      break;
126
      break;
127
    case SouthEastGravity:
127
    case SouthEastGravity:
128
    case SouthGravity:
128
    case SouthGravity:
129
    case SouthWestGravity:
129
    case SouthWestGravity:
130
      y = (s->root_attr.height - (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2)
130
      y = (s->root_attr.height - height 
131
	   - defaults.bar_border_width * 2);
131
	   - defaults.bar_border_width * 2);
132
      break;
132
      break;
133
    }
133
    }
Lines 148-156 Link Here
148
  if (bar_buffer == NULL)
148
  if (bar_buffer == NULL)
149
    bar_buffer = sbuf_new (0);
149
    bar_buffer = sbuf_new (0);
150
150
151
  get_window_list (defaults.window_fmt, NULL, bar_buffer, &mark_start, &mark_end);
151
  if(!defaults.wrap_window_list){
152
    get_window_list (defaults.window_fmt, NULL, bar_buffer, &mark_start, &mark_end);
153
    marked_message (sbuf_get (bar_buffer), mark_start, mark_end);
154
  }
155
  else{
156
    get_window_list (defaults.window_fmt, "\n", bar_buffer, &mark_start, &mark_end);
157
    marked_wrapped_message(sbuf_get (bar_buffer), mark_start, mark_end);
158
  }
152
159
153
  marked_message (sbuf_get (bar_buffer), mark_start, mark_end);
154
}
160
}
155
161
156
void
162
void
Lines 167-172 Link Here
167
  free (buffer);
173
  free (buffer);
168
}
174
}
169
175
176
177
int
178
count_lines (char* msg, int len)
179
{
180
  int ret=1;
181
  int i=0;
182
  for(; i<len; ++i) {
183
    if(msg[i]=='\n') ret++;
184
  }
185
  PRINT_DEBUG("count_lines: %d\n", ret);
186
  return ret;
187
}
188
189
190
int
191
max_line_length (char* msg)
192
{
193
  int ret=0;
194
  int i=0;
195
  int j=0;
196
  int len=strlen(msg);
197
  int current_width=0;
198
  char tmp_buf[100];
199
  
200
  for(; i<=len; ++j, ++i) {
201
    if(msg[i]=='\n' || msg[i]=='\0') {
202
      tmp_buf[j]='\0';
203
      current_width = XTextWidth (defaults.font, tmp_buf, strlen (tmp_buf));
204
      if(current_width>ret) ret=current_width;
205
      j=0;
206
    }
207
    else tmp_buf[j]=msg[i];
208
  }
209
  PRINT_DEBUG("max_line_length: %d\n", ret);
210
  return ret;
211
}
212
213
int
214
pos_in_line (char* msg, int pos)
215
{
216
  int i=pos - 1;
217
  int ret=0;
218
  if(i>=0) {
219
    for(; i<=pos && i>=0; ++ret, --i) if(msg[i]=='\n') break;
220
  }
221
  PRINT_DEBUG("pos_in_line(\"%s\", %d) = %d\n", msg, pos, ret);
222
  return ret;
223
}
224
225
int
226
line_beginning (char* msg, int pos)
227
{
228
  int ret=0;
229
  int i=pos-1;
230
  if(i) {
231
    for(; i>=0; --i) {
232
      /*      PRINT_DEBUG("pos = %d, i = %d, msg[i] = '%c'\n", pos, i, msg[i]); */
233
      if (msg[i]=='\n') {
234
	ret=i+1;
235
	break;
236
      }
237
    }
238
  }
239
  PRINT_DEBUG("line_beginning(\"%s\", %d) = %d\n", msg, pos, ret);
240
  return ret;
241
242
}
243
244
void
245
marked_wrapped_message (char *msg, int mark_start, int mark_end)
246
{
247
  XGCValues lgv;
248
  GC lgc;
249
  unsigned long mask;
250
  screen_info *s = current_screen ();
251
  int i=0;
252
  int j=0;
253
  int num_lines;
254
  int line_no=0;
255
  char tmp_buf[100];
256
257
258
259
  int width = defaults.bar_x_padding * 2 + max_line_length(msg);
260
    /* XTextWidth (defaults.font, msg, strlen (msg)); */
261
  int line_height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2);
262
  int height;
263
264
  PRINT_DEBUG ("msg = %s\n", msg);
265
  PRINT_DEBUG ("mark_start = %d, mark_end = %d\n", mark_start, mark_end);
266
267
268
  num_lines = count_lines(msg, strlen(msg));
269
  height = line_height * num_lines;
270
271
  /* Map the bar if needed */
272
  if (!s->bar_is_raised)
273
    {
274
      s->bar_is_raised = BAR_IS_MESSAGE;
275
      XMapRaised (dpy, s->bar_window);
276
    }
277
278
  /* Reset the alarm to auto-hide the bar in BAR_TIMEOUT seconds. */
279
  alarm (defaults.bar_timeout);
280
  alarm_signalled = 0;
281
282
  XMoveResizeWindow (dpy, s->bar_window, 
283
		     bar_x (s, width), bar_y (s, height),
284
		     width,
285
		     height);
286
287
  XRaiseWindow (dpy, s->bar_window);
288
  XClearWindow (dpy, s->bar_window);
289
  XSync (dpy, False);
290
291
  /*  if(!defaults.wrap_window_list){
292
    XDrawString (dpy, s->bar_window, s->normal_gc, 
293
		 defaults.bar_x_padding, 
294
		 defaults.bar_y_padding + defaults.font->max_bounds.ascent,
295
		 msg, strlen (msg));
296
		 } else { */
297
  for(i=0; i<=strlen(msg); ++i) {
298
    if (msg[i]!='\0' && msg[i]!='\n') {
299
      tmp_buf[j]=msg[i];
300
      j++;
301
    }
302
    else {
303
      tmp_buf[j]='\0';
304
      XDrawString (dpy, s->bar_window, s->normal_gc,
305
		   defaults.bar_x_padding,
306
		   defaults.bar_y_padding + defaults.font->max_bounds.ascent
307
		   +  line_no * line_height,
308
		   tmp_buf, strlen(tmp_buf));
309
      j=0;
310
      line_no++; 
311
    }
312
  }
313
 
314
315
316
  XSync (dpy, False);
317
  
318
  /* Crop to boundary conditions. */
319
  if (mark_start < 0)
320
    mark_start = 0;
321
322
  if (mark_end < 0)
323
    mark_end = 0;
324
325
  if (mark_start > strlen (msg))
326
    mark_start = strlen (msg);
327
328
  if (mark_end > strlen (msg))
329
    mark_end = strlen (msg);
330
331
  if (mark_start > mark_end+mark_start)
332
    {
333
      int tmp;
334
      tmp = mark_start;
335
      mark_start = mark_end;
336
      mark_end = tmp;
337
    }
338
339
  /* xor the string representing the current window */
340
  if (mark_end)
341
    {
342
      int start;
343
      int end;
344
      /* int width; */
345
      int start_line, 		end_line;
346
      int start_pos_in_line, 	end_pos_in_line;
347
      int start_line_beginning,	end_line_beginning;
348
349
      start_line=count_lines(msg, mark_start);
350
      end_line=count_lines(msg, mark_end+mark_start-1);
351
352
      start_pos_in_line = pos_in_line(msg, mark_start);
353
      end_pos_in_line = pos_in_line(msg, mark_end+mark_start-1);
354
355
      start_line_beginning = line_beginning(msg, mark_start);
356
      end_line_beginning = line_beginning(msg, mark_end+mark_start-1);
357
358
      PRINT_DEBUG ("start_line = %d, end_line = %d\n", start_line, end_line);
359
360
      if (mark_start == 0 || start_pos_in_line == 0)
361
	start = 0;
362
      else
363
	start = XTextWidth (defaults.font, 
364
			    &msg[start_line_beginning], 
365
			    start_pos_in_line) + defaults.bar_x_padding;
366
367
368
      end = XTextWidth (defaults.font, &msg[end_line_beginning], 
369
			end_pos_in_line + (msg[end_line_beginning+end_pos_in_line+1] == '\0'?1:0)  ) 
370
	+ defaults.bar_x_padding * 2;
371
      
372
      if (mark_end != strlen (msg))   	end -= defaults.bar_x_padding;
373
374
      /* width = end - start; */
375
376
      PRINT_DEBUG ("start = %d, end = %d, width = %d\n", start, end, width);
377
378
      lgv.foreground = current_screen()->fg_color;
379
      lgv.function = GXxor;
380
      mask = GCForeground | GCFunction;
381
      lgc = XCreateGC(dpy, s->root, mask, &lgv);
382
383
      XFillRectangle (dpy, s->bar_window, lgc, start, (start_line-1)*line_height, width, (end_line-start_line+1)*line_height);
384
385
      lgv.foreground = s->bg_color;
386
      lgc = XCreateGC(dpy, s->root, mask, &lgv);
387
388
      XFillRectangle (dpy, s->bar_window, lgc, start, (start_line-1)*line_height, width, (end_line-start_line+1)*line_height);
389
    }
390
391
  /* Keep a record of the message. */
392
  if (last_msg)
393
    free (last_msg);
394
  last_msg = xstrdup (msg);
395
  last_mark_start = mark_start;
396
  last_mark_end = mark_end;
397
}
398
170
void
399
void
171
marked_message (char *msg, int mark_start, int mark_end)
400
marked_message (char *msg, int mark_start, int mark_end)
172
{
401
{
Lines 192-198 Link Here
192
  alarm_signalled = 0;
421
  alarm_signalled = 0;
193
422
194
  XMoveResizeWindow (dpy, s->bar_window, 
423
  XMoveResizeWindow (dpy, s->bar_window, 
195
		     bar_x (s, width), bar_y (s),
424
		     bar_x (s, width), bar_y (s, height),
196
		     width,
425
		     width,
197
		     height);
426
		     height);
198
427
Lines 267-272 Link Here
267
  last_mark_start = mark_start;
496
  last_mark_start = mark_start;
268
  last_mark_end = mark_end;
497
  last_mark_end = mark_end;
269
}
498
}
499
270
500
271
void
501
void
272
show_last_message ()
502
show_last_message ()
(-)ratpoison-1.2.0.cvs.20020425/src/bar.h (-2 / +3 lines)
Lines 25-35 Link Here
25
void update_window_names (screen_info *s);
25
void update_window_names (screen_info *s);
26
int show_bar (screen_info *s);
26
int show_bar (screen_info *s);
27
int hide_bar (screen_info *s);
27
int hide_bar (screen_info *s);
28
int bar_y (screen_info *s);
28
int bar_y (screen_info *s, int height);
29
int bar_x (screen_info *s, int width);
29
int bar_x (screen_info *s, int width);
30
30
31
#define message(msg) marked_message (msg, 0, 0)
31
#define message(msg) marked_message ((msg), 0, 0)
32
void marked_message (char *msg, int hl_start, int hl_end);
32
void marked_message (char *msg, int hl_start, int hl_end);
33
void marked_wrapped_message (char *msg, int hl_start, int hl_end);
33
void marked_message_printf (int mark_start, int mark_end, char *fmt, ...);
34
void marked_message_printf (int mark_start, int mark_end, char *fmt, ...);
34
void show_last_message ();
35
void show_last_message ();
35
36
(-)ratpoison-1.2.0.cvs.20020425/src/data.h (+2 lines)
Lines 160-165 Link Here
160
  int win_name;
160
  int win_name;
161
161
162
  int startup_message;
162
  int startup_message;
163
164
  int wrap_window_list;
163
};
165
};
164
166
165
extern struct rp_defaults defaults;
167
extern struct rp_defaults defaults;
(-)ratpoison-1.2.0.cvs.20020425/src/input.c (-3 / +5 lines)
Lines 278-295 Link Here
278
{
278
{
279
  int 	prompt_width = XTextWidth (defaults.font, prompt, strlen (prompt));
279
  int 	prompt_width = XTextWidth (defaults.font, prompt, strlen (prompt));
280
  int 	input_width  = XTextWidth (defaults.font, input, input_len);
280
  int 	input_width  = XTextWidth (defaults.font, input, input_len);
281
  int 	width;
281
  int 	width, height;
282
282
283
  width = defaults.bar_x_padding * 2 + prompt_width + input_width;
283
  width = defaults.bar_x_padding * 2 + prompt_width + input_width;
284
  height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2);
284
285
285
  if (width < defaults.input_window_size + prompt_width)
286
  if (width < defaults.input_window_size + prompt_width)
286
    {
287
    {
287
      width = defaults.input_window_size + prompt_width;
288
      width = defaults.input_window_size + prompt_width;
288
    }
289
    }
289
290
291
  
292
290
  XMoveResizeWindow (dpy, s->input_window, 
293
  XMoveResizeWindow (dpy, s->input_window, 
291
		     bar_x (s, width), bar_y (s), width,
294
		     bar_x (s, width), bar_y (s, height), width, height);
292
		     (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2));
293
295
294
  XClearWindow (dpy, s->input_window);
296
  XClearWindow (dpy, s->input_window);
295
  XSync (dpy, False);
297
  XSync (dpy, False);
(-)ratpoison-1.2.0.cvs.20020425/src/list.c (-3 / +9 lines)
Lines 19-24 Link Here
19
 * Boston, MA 02111-1307 USA
19
 * Boston, MA 02111-1307 USA
20
 */
20
 */
21
21
22
22
#include <stdio.h>
23
#include <stdio.h>
23
#include <stdlib.h>
24
#include <stdlib.h>
24
#include <string.h>
25
#include <string.h>
Lines 740-746 Link Here
740
741
741
      if (w == current_window())
742
      if (w == current_window())
742
	*mark_start = strlen (sbuf_get (buffer));
743
	*mark_start = strlen (sbuf_get (buffer));
743
744
      
744
      /* A hack, pad the window with a space at the beginning and end
745
      /* A hack, pad the window with a space at the beginning and end
745
         if there is no delimiter. */
746
         if there is no delimiter. */
746
      if (!delim)
747
      if (!delim)
Lines 758-765 Link Here
758
      if (delim && w->next != rp_mapped_window_sentinel)
759
      if (delim && w->next != rp_mapped_window_sentinel)
759
	sbuf_concat (buffer, delim);
760
	sbuf_concat (buffer, delim);
760
761
761
      if (w == current_window())
762
      if (w == current_window()) {
762
	*mark_end = strlen (sbuf_get (buffer));
763
	if(!defaults.wrap_window_list){
764
	  *mark_end = strlen (sbuf_get (buffer));
765
	} else {
766
	  *mark_end = strlen (sbuf_get(buffer))- *mark_start;
767
	}
768
      }
763
    }
769
    }
764
770
765
  if (!strcmp (sbuf_get (buffer), ""))
771
  if (!strcmp (sbuf_get (buffer), ""))
(-)ratpoison-1.2.0.cvs.20020425/src/main.c (+1 lines)
Lines 445-450 Link Here
445
445
446
  defaults.win_name = 0;
446
  defaults.win_name = 0;
447
  defaults.startup_message = 1;
447
  defaults.startup_message = 1;
448
  defaults.wrap_window_list = 1;
448
}
449
}
449
450
450
int
451
int

Return to bug 15932